Quittio next API

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

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
self

get()

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
string

has()

public has(string $key[, string|null $locale = null ]) : bool
Parameters
$key : string
$locale : string|null = null
Return values
bool

setLocale()

public setLocale(string $locale) : self
Parameters
$locale : string
Return values
self
On this page

Search results