API / Minn\I18n / TextDomains

TextDomains final class

Minn\I18n\TextDomains · public/minn/src/Minn/I18n/TextDomains.php · 191 lines

The text domains this request knows: each domain's files in the order they were loaded, and the domains looked for and not found (known, with no files), all in the order they first appeared, which is the order a locale switch reloads them in. A lookup asks a domain's files in load order and the first one with a translation answers, each under its own plural rule. The registry also remembers the folder a plugin or theme named for its domain (and how files there are named), and the domains unloaded for good.

Uses 1

Constants and properties

privatearray $loaded
privatearray $folders
privatearray $closed
privatearray $lookAgain
privatearray $accepted

Public

methodadd(string $domain, string $file, Minn\I18n\Catalog $catalog): void#

Adds a loaded file to a domain; a file already loaded there is not added twice.

methodhas(string $domain): bool#

Whether any file is loaded for the domain.

methodunload(string $domain): bool#

Forgets a domain and its files; true when it had any.

methodaccept(string $domain): void#

Records that load_textdomain() loaded a file for the domain. A file that does not parse adds nothing to look up, yet the reference's global functions count its domain as loaded, while its translation controller does not (probe translations-early-wplang).

methodopened(string $domain): bool#

Whether the global functions count the domain as loaded: a file loaded, or one load_textdomain() accepted.

methodmarkKnown(string $domain): void#

Records that a domain was asked for, so it is looked for once and reloaded on a switch.

methodwaiting(string $domain): bool#

Whether a translation lookup should look for the domain's files: it was never looked for, or nothing was found and a folder has been named for it since (the reference looks again after each load_plugin_textdomain; probe plugin-data).

methodknown(string $domain): bool#

Whether the domain was loaded or looked for.

methodknownDomains(): array#

Every known domain, in the order it first appeared.

@return list<string>
methodunloadFile(string $domain, string $file): bool#

Drops one file from a domain; true when it was loaded.

methodcatalogs(string $domain): array#

The domain's files and catalogs, first loaded first.

@return array<string, Catalog>
methodtranslate(string $domain, string $key): ?string#

The first loaded translation of a key in the domain, or null.

methodtranslatePlural(string $domain, array $keys, int $count): ?string#

The first loaded plural form for a count, or null: each key is looked for in every file before the next key (the full "singular NUL plural" key, then the singular alone).

$keyslist<string>
methodrememberFolder(string $domain, string $folder): void#

Records the folder a plugin or theme named for its domain; files there are "{domain}-{locale}".

methodrememberThemeFolder(string $domain, string $folder): void#

Records the active theme's own language folder; files there are named by locale alone.

methodfolderFile(string $domain, string $locale): ?string#

The .mo path a domain's named folder would hold for a locale, if a folder was named.

methodclose(string $domain): void#

Keeps an unloaded domain from loading again on its own.

methodclosed(string $domain): bool#

Whether the domain was unloaded for good.

methoddomains(): array#

The domains with files loaded.

@return list<string>

Internals 1

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatelookAgainUnlessLoaded(string $domain): void#