Locale - viames/pair GitHub Wiki
Pair framework: Locale
Pair\Models\Locale is the ActiveRecord model for locales (language + country), translation files, and app default locale behavior.
Important methods
Locale selection
getDefault(): ?LocalegetByRepresentation(string $representation): ?Locale(e.g.en-GB)getDefaultByLanguage(string $languageCode): ?Locale
Locale info
getRepresentation(string $separator = '-'): stringisDefault(): boolisOfficialLanguage(): boolisDefaultCountry(): bool
Translation files
getFilePath(string $module): stringreadTranslation(?Module $module): arraywriteTranslation(array $strings, ?Module $module): boolisFileWritable(string $moduleName): bool
Implementation examples
$locale = \Pair\Models\Locale::getByRepresentation('en-GB');
$code = $locale?->getRepresentation();
Read common translations:
$strings = $locale->readTranslation(null);
Write module translations:
$locale->writeTranslation([
'WELCOME' => 'Welcome',
'SAVE' => 'Save'
], $module);
See also: Translator, User, Configuration-file.