class IdentityTranslator in Plug 7
IdentityTranslator does not translate anything.
@author Fabien Potencier <fabien@symfony.com>
@api
Hierarchy
- class \Symfony\Component\Translation\IdentityTranslator implements TranslatorInterface
Expanded class hierarchy of IdentityTranslator
1 file declares its use of IdentityTranslator
- IdentityTranslatorTest.php in lib/
Symfony/ translation/ Tests/ IdentityTranslatorTest.php
File
- lib/
Symfony/ translation/ IdentityTranslator.php, line 21
Namespace
Symfony\Component\TranslationView source
class IdentityTranslator implements TranslatorInterface {
private $selector;
private $locale;
/**
* Constructor.
*
* @param MessageSelector|null $selector The message selector for pluralization
*
* @api
*/
public function __construct(MessageSelector $selector = null) {
$this->selector = $selector ?: new MessageSelector();
}
/**
* {@inheritdoc}
*
* @api
*/
public function setLocale($locale) {
$this->locale = $locale;
}
/**
* {@inheritdoc}
*
* @api
*/
public function getLocale() {
return $this->locale ?: \Locale::getDefault();
}
/**
* {@inheritdoc}
*
* @api
*/
public function trans($id, array $parameters = array(), $domain = null, $locale = null) {
return strtr((string) $id, $parameters);
}
/**
* {@inheritdoc}
*
* @api
*/
public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null) {
return strtr($this->selector
->choose((string) $id, (int) $number, $locale ?: $this
->getLocale()), $parameters);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
IdentityTranslator:: |
private | property | ||
IdentityTranslator:: |
private | property | ||
IdentityTranslator:: |
public | function |
@api Overrides TranslatorInterface:: |
|
IdentityTranslator:: |
public | function |
@api Overrides TranslatorInterface:: |
|
IdentityTranslator:: |
public | function |
@api Overrides TranslatorInterface:: |
|
IdentityTranslator:: |
public | function |
@api Overrides TranslatorInterface:: |
|
IdentityTranslator:: |
public | function | Constructor. |