class TranslatorAdapter implements TranslatorAdapterInterface (View source)

Translator adapter that wraps the Zend translator to provide the translator methods needed in concrete5.

Properties

protected $translator

Methods

__construct(Translator $translator)

No description

setTranslator(Translator $translator)

Sets the translator object.

mixed
getTranslator()

Returns an instance of a translator object.

string
getLocale()

Get the locale from the translator object.

setLocale(string $locale)

Sets the locale to the translator object.

string
translate(string $text)

Translate the given text. Returns the translated form of the text.

int
translatePlural(string $singular, string $plural, int $number)

Translate the text either into the singular or the plural format depending on the given number. Returns the correct format of the text in its translated form.

string
translateContext(string $context, string $text)

Translate the given text with the given context. Returns the translated form of the text.

formatString(string $string, array $args)

Formats the string in the with the PHP sprintf format with the given arguments.

Details

__construct(Translator $translator)

Parameters

Translator $translator

setTranslator(Translator $translator)

Sets the translator object.

Parameters

Translator $translator

mixed getTranslator()

Returns an instance of a translator object.

Return Value

mixed The translator object

string getLocale()

Get the locale from the translator object.

Return Value

string

setLocale(string $locale)

Sets the locale to the translator object.

Parameters

string $locale

string translate(string $text)

Translate the given text. Returns the translated form of the text.

Parameters

string $text

Return Value

string

int translatePlural(string $singular, string $plural, int $number)

Translate the text either into the singular or the plural format depending on the given number. Returns the correct format of the text in its translated form.

Parameters

string $singular
string $plural
int $number

Return Value

int

string translateContext(string $context, string $text)

Translate the given text with the given context. Returns the translated form of the text.

Parameters

string $context
string $text

Return Value

string

protected formatString(string $string, array $args)

Formats the string in the with the PHP sprintf format with the given arguments.

Parameters

string $string
array $args