Skip to content
Viames Marino edited this page Feb 23, 2026 · 1 revision

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(): ?Locale
  • getByRepresentation(string $representation): ?Locale (e.g. en-GB)
  • getDefaultByLanguage(string $languageCode): ?Locale

Locale info

  • getRepresentation(string $separator = '-'): string
  • isDefault(): bool
  • isOfficialLanguage(): bool
  • isDefaultCountry(): bool

Translation files

  • getFilePath(string $module): string
  • readTranslation(?Module $module): array
  • writeTranslation(array $strings, ?Module $module): bool
  • isFileWritable(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.

Clone this wiki locally