Class

Symfony\Component\Translation\Translator

class Translator implements TranslatorInterface

Translator.

Methods

__construct(string $locale, MessageSelector $selector)

Constructor.

addLoader(string $format, LoaderInterface $loader)

Adds a Loader.

addResource(string $format, mixed $resource, string $locale, string $domain = 'messages')

Adds a Resource.

setLocale(string $locale)

Sets the current locale.

string getLocale()

Returns the current locale.

setFallbackLocale(string $locale)

Sets the fallback locale.

string trans(string $id, array $parameters = array(), string $domain = 'messages', string $locale = null)

Translates the given message.

string transChoice(string $id, integer $number, array $parameters = array(), string $domain = 'messages', string $locale = null)

Translates the given choice message by choosing a translation according to a number.

Details

at line 40
public __construct(string $locale, MessageSelector $selector)

Constructor.

Parameters

string $locale The locale
MessageSelector $selector The message selector for pluralization

at line 57
public addLoader(string $format, LoaderInterface $loader)

Adds a Loader.

Parameters

string $format The name of the loader (see addResource())
LoaderInterface $loader A LoaderInterface instance

at line 72
public addResource(string $format, mixed $resource, string $locale, string $domain = 'messages')

Adds a Resource.

Parameters

string $format The name of the loader (see addLoader())
mixed $resource The resource name
string $locale The locale
string $domain The domain

at line 84
public setLocale(string $locale)

Sets the current locale.

Parameters

string $locale The locale

at line 94
public string getLocale()

Returns the current locale.

Return Value

string The locale

at line 106
public setFallbackLocale(string $locale)

Sets the fallback locale.

Parameters

string $locale The fallback locale

at line 119
public string trans(string $id, array $parameters = array(), string $domain = 'messages', string $locale = null)

Translates the given message.

Parameters

string $id The message id
array $parameters An array of parameters for the message
string $domain The domain for the message
string $locale The locale

Return Value

string The translated string

at line 137
public string transChoice(string $id, integer $number, array $parameters = array(), string $domain = 'messages', string $locale = null)

Translates the given choice message by choosing a translation according to a number.

Parameters

string $id The message id
integer $number The number to use to find the indice of the message
array $parameters An array of parameters for the message
string $domain The domain for the message
string $locale The locale

Return Value

string The translated string