API / Minn\I18n / Catalog

Catalog final readonly class

Minn\I18n\Catalog · public/minn/src/Minn/I18n/Catalog.php · 56 lines

One translation file's contents: its headers as written, its messages keyed the gettext way (the context, a 0x04 byte, then the original; the original alone without a context), each with its translated forms and, where the file says, the original plural, and the file's plural rule. An empty translation is still a translation: it is what the file says.

Constants and properties

propreadonly array $headers

Promoted from the constructor.

propreadonly array $entries

Promoted from the constructor.

propreadonly Minn\I18n\PluralRule $plural

Promoted from the constructor.

Public

new__construct(array $headers, array $entries, Minn\I18n\PluralRule $plural)#
$headersarray<string, string>
$entriesarray<string, array{translations: list<string>, plural: ?string}>
staticfrom(array $headers, array $entries): self#

A catalog from headers and entries, its plural rule taken from the headers.

statickey(string $original, ?string $context): string#

The lookup key for an original in a context; an empty or missing context is no context.

methodheaderValue(string $name): ?string#

A header's value, its name matched without case.

methodtranslate(string $key): ?string#

The translation of a message, empty when the file says so, or null when the file has no entry.

methodtranslatePlural(string $key, int $count): ?string#

The form of a message a count takes under this file's rule (the first form when the file has fewer), or null when the file has no entry.

methodhas(string $key): bool#

Whether the file has an entry for the message.