API reference / Quittio \ Core \ I18n
ArrayTranslator
final class in quittio/core · implements Translator
Quittio\Core\I18n\ArrayTranslator · Source
Translator backed by PHP array files: {path}/{locale}/{group}.php.
Keys follow Laravel's convention "namespace::group.key". Paths are registered per namespace; later paths override earlier ones. Missing keys fall back to the language of a regional locale ("de" for "de_CH"), to the fallback locale and finally to the key itself. Item keys may contain dots (e.g. "de.standard"); a flat key wins over a nested lookup.
Constants#
| Constant | Value | Description |
|---|---|---|
CORE_NAMESPACE | 'quittio' |
Methods#
| Method | Description |
|---|---|
->__construct() | |
->addPath() | |
->get() | |
->has() | |
::language() | The language of a regional locale: "de" for "de_CH" or "de-CH". |
->locale() | |
->setLocale() |
__construct()#
public function __construct(string $locale = 'en', string $fallbackLocale = 'en')| Parameter | Type | Description |
|---|---|---|
$locale | string = 'en' | |
$fallbackLocale | string = 'en' |
addPath()#
public function addPath(string $path, string $namespace = '*'): self| Parameter | Type | Description |
|---|---|---|
$path | string | |
$namespace | string = '*' |
- Returns
self
get()#
public function get(string $key, array $replace = [], ?string $locale = null): string| Parameter | Type | Description |
|---|---|---|
$key | string | |
$replace | array = [] | |
$locale | ?string = null |
- Returns
string
has()#
public function has(string $key, ?string $locale = null): bool| Parameter | Type | Description |
|---|---|---|
$key | string | |
$locale | ?string = null |
- Returns
bool
language()#
public static function language(string $locale): stringThe language of a regional locale: "de" for "de_CH" or "de-CH".
| Parameter | Type | Description |
|---|---|---|
$locale | string |
- Returns
string
locale()#
public function locale(): string- Returns
string
setLocale()#
public function setLocale(string $locale): self| Parameter | Type | Description |
|---|---|---|
$locale | string |
- Returns
self