Class

Symfony\Bundle\FrameworkBundle\Translation\Translator

class Translator extends Translator

Translator.

Methods

__construct(ContainerInterface $container, MessageSelector $selector, array $loaderIds = array(), array $options = array(), Session $session = null)

Constructor.

addLoader(string $format, LoaderInterface $loader)

Adds a Loader.

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

Adds a Resource.

from Translator
setLocale(string $locale)

Sets the current locale.

from Translator
string getLocale()

Returns the current locale.

setFallbackLocale(string $locale)

Sets the fallback locale.

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

Translates the given message.

from Translator
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.

from Translator

Details

at line 46
public __construct(ContainerInterface $container, MessageSelector $selector, array $loaderIds = array(), array $options = array(), Session $session = null)

Constructor.

Available options:

Parameters

ContainerInterface $container A ContainerInterface instance
MessageSelector $selector The message selector for pluralization
array $loaderIds An array of loader Ids
array $options An array of options
Session $session A Session instance

in Translator 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

in Translator 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

in Translator at line 84
public setLocale(string $locale)

Sets the current locale.

Parameters

string $locale The locale

at line 70
public string getLocale()

Returns the current locale.

Return Value

string The locale

in Translator at line 106
public setFallbackLocale(string $locale)

Sets the fallback locale.

Parameters

string $locale The fallback locale

in Translator 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

in Translator 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