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
| private | RTL = 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', ) | |
| private | readonly Minn\Content\Users $users | Promoted from the constructor. |
| private | readonly Minn\Content\Site $site | Promoted from the constructor. |
| private | readonly Minn\Admin\App $app | Promoted from the constructor. |
| private | readonly string $contentDir | Promoted from the constructor. |
| private | readonly 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, )))# | |
| method | localeOf(int $userId): string# | The locale a person reads the admin in. |
| method | siteLocale(): string# | The site's locale from WPLANG, en_US by default. |
| static | isRtl(string $locale): bool# | Whether a locale reads right to left. |
| method | catalog(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 |
| method | isInstalled(string $locale): bool# | Whether a locale has any files on this site: a core pack or Minn Admin's own. |
| method | installed(): 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 |
| method | payload(int $forUser): array# | The languages route's payload; `current` is the raw meta of the user asked about. |
| method | readOnlyPayload(int $forUser): array# | The same payload for a caller who may switch languages but not install one: no available list. |
| method | install(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.
| private | languages(int $forUser, bool $canInstall): array# | |
| private | catalogFiles(string $locale): array# | @return list<string> |
| private | installedCodes(): array# | @return list<string> locale codes with a core pack or a Minn Admin pack on disk, sorted |
| private | names(): array# | Native names for every locale the registry lists, from the captured catalog. @return array<string, string> @return array<string, string> |
| private | download(string $url): string# |
Nothing matches.