class TranslatorAdapter implements TranslatorAdapterInterface (View source)

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

Properties

protected string $locale

Methods

mixed
getTranslator()

The plain translator does not have any translator object attached to it, so null is returned instead.

string
getLocale()

Get the locale from the translator object.

setLocale(string $locale)

Sets the locale to the translator object.

string
translate(string $text)

Dummy translate method for the plain translator adapter.

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

Dummy plural translate method for the plain translator.

string
translateContext(string $context, string $text)

Dummy translate context method for the plain translator adapter.

formatString(string $string, array $args)

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

Details

mixed getTranslator()

The plain translator does not have any translator object attached to it, so null is returned instead.

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)

Dummy translate method for the plain translator adapter.

Returns the same string that is passed to this method formatted with the sprintf format in case multiple arguments are passed.

Parameters

string $text

Return Value

string

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

Dummy plural translate method for the plain translator.

Does not do any actual translation but returns the correct format of the two provided strings ($singular and $plural) based on the passed number parameter ($number).

If the $number is equal to 1, the singular format will be returned.

If the $number is not equal to 1, the plural format will be returned.

Parameters

string $singular
string $plural
int $number

Return Value

int

string translateContext(string $context, string $text)

Dummy translate context method for the plain translator adapter.

Does exactly the same as the translate() method, skipping the passed context string as it is not used.

Calls the translate() method with other arguments than the context.

Parameters

string $context
string $text

Return Value

string

See also

TranslatorAdapter::translate

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