Translator
class Translator extends NamespacedItemResolver implements TranslatorInterface (View source)
Methods
Parse a key into namespace, group, and item.
Set the parsed value of a key.
Determine if a translation exists for a given locale.
Determine if a translation exists.
Get the translation for the given key.
Get the translation for a given key.
Get a translation according to an integer value.
Load the specified language group.
Add a new namespace to the loader.
Get the message selector instance.
Set the message selector instance.
Get the language line loader implementation.
Get the default locale being used.
Get the default locale being used.
Set the default locale.
Get the fallback locale being used.
Set the fallback locale being used.
Details
in NamespacedItemResolver at line line 100
void
setParsedKey(
string $key,
array $parsed)
Set the parsed value of a key.
at line line 56
void
__construct(
LoaderInterface $loader,
string $locale)
Create a new translator instance.
at line line 69
bool
hasForLocale(
string $key,
string|null $locale = null)
Determine if a translation exists for a given locale.
at line line 82
bool
has(
string $key,
string|null $locale = null,
bool $fallback = true)
Determine if a translation exists.
at line line 96
string|array|null
get(
string $key,
array $replace = array(),
string|null $locale = null,
bool $fallback = true)
Get the translation for the given key.
at line line 192
string
choice(
string $key,
int|array|Countable $number,
array $replace = array(),
string $locale = null)
Get a translation according to an integer value.
at line line 214
string|array|null
trans(
string $id,
array $parameters = array(),
string $domain = 'messages',
string $locale = null)
Get the translation for a given key.
at line line 229
string
transChoice(
string $id,
int|array|Countable $number,
array $parameters = array(),
string $domain = 'messages',
string $locale = null)
Get a translation according to an integer value.
at line line 242
void
load(
string $namespace,
string $group,
string $locale)
Load the specified language group.
at line line 276
void
addNamespace(
string $namespace,
string $hint)
Add a new namespace to the loader.