TranslatorInterface
extends
LocaleAwareInterface
in
TranslatorInterface.
Tags
Table of Contents
- getLocale() : string
- Returns the current locale.
- setLocale() : mixed
- Sets the current locale.
- trans() : string
- Translates the given message.
- transChoice() : string
- Translates the given choice message by choosing a translation according to a number.
Methods
getLocale()
Returns the current locale.
public
getLocale() : string
Return values
string —The locale
setLocale()
Sets the current locale.
public
setLocale(string $locale) : mixed
Parameters
- $locale : string
-
The locale
Tags
Return values
mixed —trans()
Translates the given message.
public
trans(string $id[, array<string|int, mixed> $parameters = [] ][, string|null $domain = null ][, string|null $locale = null ]) : string
Parameters
- $id : string
-
The message id (may also be an object that can be cast to string)
- $parameters : array<string|int, mixed> = []
-
An array of parameters for the message
- $domain : string|null = null
-
The domain for the message or null to use the default
- $locale : string|null = null
-
The locale or null to use the default
Tags
Return values
string —The translated string
transChoice()
Translates the given choice message by choosing a translation according to a number.
public
transChoice(string $id, int $number[, array<string|int, mixed> $parameters = [] ][, string|null $domain = null ][, string|null $locale = null ]) : string
Parameters
- $id : string
-
The message id (may also be an object that can be cast to string)
- $number : int
-
The number to use to find the index of the message
- $parameters : array<string|int, mixed> = []
-
An array of parameters for the message
- $domain : string|null = null
-
The domain for the message or null to use the default
- $locale : string|null = null
-
The locale or null to use the default
Tags
Return values
string —The translated string