interface Translator

Methods

array|string
get(string $key, array $replace = [], string|null $locale = null, bool $fallback = true)

Get the translation for a given key.

string
string(string $key, array $replace = [], string|null $locale = null, bool $fallback = true)

Get the specified string translation value.

array
array(string $key, array $replace = [], string|null $locale = null, bool $fallback = true)

Get the specified array translation value.

string
choice(string $key, array|Countable|float|int $number, array $replace = [], string|null $locale = null)

Get a translation according to an integer value.

string
getLocale()

Get the current locale being used.

void
setLocale(string $locale)

Set the current locale.

string
getFallback()

Get the fallback locale being used.

void
setFallback(string $fallback)

Set the fallback locale being used.

Details

at line 14
array|string get(string $key, array $replace = [], string|null $locale = null, bool $fallback = true)

Get the translation for a given key.

Parameters

string $key
array $replace
string|null $locale
bool $fallback

Return Value

array|string

at line 19
string string(string $key, array $replace = [], string|null $locale = null, bool $fallback = true)

Get the specified string translation value.

Parameters

string $key
array $replace
string|null $locale
bool $fallback

Return Value

string

at line 26
array array(string $key, array $replace = [], string|null $locale = null, bool $fallback = true)

Get the specified array translation value.

Parameters

string $key
array $replace
string|null $locale
bool $fallback

Return Value

array

at line 31
string choice(string $key, array|Countable|float|int $number, array $replace = [], string|null $locale = null)

Get a translation according to an integer value.

Parameters

string $key
array|Countable|float|int $number
array $replace
string|null $locale

Return Value

string

at line 36
string getLocale()

Get the current locale being used.

Return Value

string

at line 41
void setLocale(string $locale)

Set the current locale.

Parameters

string $locale

Return Value

void

at line 46
string getFallback()

Get the fallback locale being used.

Return Value

string

at line 55
void setFallback(string $fallback)

Set the fallback locale being used.

Boot-only. The fallback is shared by the worker's Translator instance and affects every subsequent translation lookup in that worker. Use setLocale() for a current-request locale override.

Parameters

string $fallback

Return Value

void