API reference / Quittio \ Core \ I18n
Translator
interface in quittio/core
Quittio\Core\I18n\Translator · Source
Minimal translator contract so that the core works without Laravel. Keys use the form "group.key" (e.g. "labels.due_date", "rules.BR-CO-25.message").
Methods#
| Method | Description |
|---|---|
->addPath() | Registers a directory with {locale}/{group}.php files for a namespace (e.g. "quittio-de"). |
->get() | |
->has() | |
->locale() |
addPath()#
public function addPath(string $path, string $namespace = '*'): selfRegisters a directory with {locale}/{group}.php files for a namespace (e.g. "quittio-de").
| Parameter | Type | Description |
|---|---|---|
$path | string | |
$namespace | string = '*' |
- Returns
self
get()#
public function get(
string $key,
array<string, string|int> $replace = [],
?string $locale = null,
): string| Parameter | Type | Description |
|---|---|---|
$key | string | |
$replace | array<string, string|int> = [] | |
$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
locale()#
public function locale(): string- Returns
string