Zum Inhalt springen

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#

ConstantValueDescription
CORE_NAMESPACE'quittio'

Methods#

MethodDescription
->__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')
ParameterTypeDescription
$localestring = 'en'
$fallbackLocalestring = 'en'

addPath()#

public function addPath(string $path, string $namespace = '*'): self
ParameterTypeDescription
$pathstring
$namespacestring = '*'
Returns
self

get()#

public function get(string $key, array $replace = [], ?string $locale = null): string
ParameterTypeDescription
$keystring
$replacearray = []
$locale?string = null
Returns
string

has()#

public function has(string $key, ?string $locale = null): bool
ParameterTypeDescription
$keystring
$locale?string = null
Returns
bool

language()#

public static function language(string $locale): string

static

The language of a regional locale: "de" for "de_CH" or "de-CH".

ParameterTypeDescription
$localestring
Returns
string

locale()#

public function locale(): string
Returns
string

setLocale()#

public function setLocale(string $locale): self
ParameterTypeDescription
$localestring
Returns
self

Die Open-Core-Pakete stehen unter der MIT-Lizenz. Die rechtlichen Formulierungen der Länderpakete sind mit einer Steuerberatung abzustimmen.