ArrayTranslator
in package
implements
Translator
FinalYes
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 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.
Table of Contents
Interfaces
- Translator
- Minimal translator contract so that the core works without Laravel.
Constants
- CORE_NAMESPACE : string = 'quittio'
Methods
- __construct() : mixed
- addPath() : self
- Registers a directory with {locale}/{group}.php files for a namespace (e.g. "quittio-de").
- get() : string
- has() : bool
- locale() : string
- setLocale() : self
Constants
CORE_NAMESPACE
public
string
CORE_NAMESPACE
= 'quittio'
Methods
__construct()
public
__construct([string $locale = 'en' ][, string $fallbackLocale = 'en' ]) : mixed
Parameters
- $locale : string = 'en'
- $fallbackLocale : string = 'en'
addPath()
Registers a directory with {locale}/{group}.php files for a namespace (e.g. "quittio-de").
public
addPath(string $path[, string $namespace = '*' ]) : self
Parameters
- $path : string
- $namespace : string = '*'
Return values
selfget()
public
get(string $key[, array<string|int, mixed> $replace = [] ][, string|null $locale = null ]) : string
Parameters
- $key : string
- $replace : array<string|int, mixed> = []
- $locale : string|null = null
Return values
stringhas()
public
has(string $key[, string|null $locale = null ]) : bool
Parameters
- $key : string
- $locale : string|null = null
Return values
boollocale()
public
locale() : string
Return values
stringsetLocale()
public
setLocale(string $locale) : self
Parameters
- $locale : string