API / Minn\Admin / Translations

Translations final readonly class

Minn\Admin\Translations · public/minn/src/Minn/Admin/Translations.php · 237 lines

Languages for the admin. A person's locale is their `locale` user meta, else the site's WPLANG, else en_US, exactly as the reference resolves it. The app translates itself from a map of its source strings, read from the JED catalogs Minn Admin's language packs install under wp-content/languages/plugins (the bundle's own languages folder is the fallback). Installing a pack fetches the release asset the bundle's manifest names for that locale, checks its hash, and unpacks only that locale's files, so an eject leaves the files WordPress would have written.

Constants and properties

privateRTL = array ( 0 => 'ar', 1 => 'ary', 2 => 'azb', 3 => 'ckb', 4 => 'dv', 5 => 'fa_AF', 6 => 'fa_IR', 7 => 'haz', 8 => 'he_IL', 9 => 'ps', 10 => 'skr', 11 => 'ug_CN', 12 => 'ur', )
privatereadonly Minn\Content\Users $users

Promoted from the constructor.

privatereadonly Minn\Content\Site $site

Promoted from the constructor.

privatereadonly Minn\Admin\App $app

Promoted from the constructor.

privatereadonly string $contentDir

Promoted from the constructor.

privatereadonly Minn\Http $http

Promoted from the constructor.

Public

new__construct(Minn\Content\Users $users, Minn\Content\Site $site, Minn\Admin\App $app, string $contentDir, Minn\Http $http = \Minn\Http::__set_state(array( 'within' => array ( ), 'fake' => NULL, 'refusal' => NULL, )))#
methodlocaleOf(int $userId): string#

The locale a person reads the admin in.

methodsiteLocale(): string#

The site's locale from WPLANG, en_US by default.

staticisRtl(string $locale): bool#

Whether a locale reads right to left.

methodcatalog(string $locale): array#

The app's translation map for a locale: source string => translation, or the plural forms as a list. Later folders win, so the installed pack lands over the bundle's fallback.

@return array{0: array<string, string|list<string>>, 1: string} map and the Plural-Forms rule
methodisInstalled(string $locale): bool#

Whether a locale has any files on this site: a core pack or Minn Admin's own.

methodinstalled(): array#

The locales with a pack on disk, the two defaults first.

@return list<array{0: string, 1: string}> the site-default row, en_US, then every installed locale
methodpayload(int $forUser): array#

The languages route's payload; `current` is the raw meta of the user asked about.

methodreadOnlyPayload(int $forUser): array#

The same payload for a caller who may switch languages but not install one: no available list.

methodinstall(string $locale): bool#

Fetches and unpacks Minn Admin's language pack for a locale from the release the bundle's manifest names. True when files were written; false when the manifest offers no pack for the locale.

Internals 5

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

privatelanguages(int $forUser, bool $canInstall): array#
privatecatalogFiles(string $locale): array#
@return list<string>
privateinstalledCodes(): array#
@return list<string> locale codes with a core pack or a Minn Admin pack on disk, sorted
privatenames(): array#

Native names for every locale the registry lists, from the captured catalog. @return array<string, string>

@return array<string, string>
privatedownload(string $url): string#