Symfony\Component\Validator\DefaultTranslator
Simple translator implementation that simply replaces the parameters in the message IDs.
Example usage:
$translator = new DefaultTranslator();
echo $translator->trans(
'This is a {{ var }}.',
array('{{ var }}' => 'donkey')
);
// -> This is a donkey.
echo $translator->transChoice(
'This is {{ count }} donkey.|These are {{ count }} donkeys.',
3,
array('{{ count }}' => 'three')
);
// -> These are three donkeys.
This translator does not support message catalogs, translation domains or
locales. Instead, it implements a subset of the capabilities of
{@link \Symfony\Component\Translation\Translator} and can be used in places
where translation is not required by default but should be optional.
- Author: Bernhard Schussek <bschussek@gmail.com>
Synopsis
class DefaultTranslator
implements
TranslatorInterface
{
- // methods
- public string trans()
- public string transChoice()
- public void setLocale()
- public string getLocale()
Hierarchy
Methods
public
- getLocale() — Returns the locale of the translator.
- setLocale() — Not supported.
- trans() — Interpolates the given message.
- transChoice() — Interpolates the given choice message by choosing a variant according to a number.