You are here

class IdentityTranslator in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/translation/IdentityTranslator.php \Symfony\Component\Translation\IdentityTranslator

IdentityTranslator does not translate anything.

@author Fabien Potencier <fabien@symfony.com>

Hierarchy

Expanded class hierarchy of IdentityTranslator

6 files declare their use of IdentityTranslator
IdentityTranslatorTest.php in vendor/symfony/translation/Tests/IdentityTranslatorTest.php
LegacyValidator2Dot5ApiTest.php in vendor/symfony/validator/Tests/Validator/LegacyValidator2Dot5ApiTest.php
LegacyValidatorLegacyApiTest.php in vendor/symfony/validator/Tests/Validator/LegacyValidatorLegacyApiTest.php
LegacyValidatorTest.php in vendor/symfony/validator/Tests/LegacyValidatorTest.php
RecursiveValidator2Dot5ApiTest.php in vendor/symfony/validator/Tests/Validator/RecursiveValidator2Dot5ApiTest.php

... See full list

File

vendor/symfony/translation/IdentityTranslator.php, line 19

Namespace

Symfony\Component\Translation
View source
class IdentityTranslator implements TranslatorInterface {
  private $selector;
  private $locale;

  /**
   * Constructor.
   *
   * @param MessageSelector|null $selector The message selector for pluralization
   */
  public function __construct(MessageSelector $selector = null) {
    $this->selector = $selector ?: new MessageSelector();
  }

  /**
   * {@inheritdoc}
   */
  public function setLocale($locale) {
    $this->locale = $locale;
  }

  /**
   * {@inheritdoc}
   */
  public function getLocale() {
    return $this->locale ?: \Locale::getDefault();
  }

  /**
   * {@inheritdoc}
   */
  public function trans($id, array $parameters = array(), $domain = null, $locale = null) {
    return strtr((string) $id, $parameters);
  }

  /**
   * {@inheritdoc}
   */
  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

Namesort descending Modifiers Type Description Overrides
IdentityTranslator::$locale private property
IdentityTranslator::$selector private property
IdentityTranslator::getLocale public function Returns the current locale. Overrides TranslatorInterface::getLocale
IdentityTranslator::setLocale public function Sets the current locale. Overrides TranslatorInterface::setLocale
IdentityTranslator::trans public function Translates the given message. Overrides TranslatorInterface::trans
IdentityTranslator::transChoice public function Translates the given choice message by choosing a translation according to a number. Overrides TranslatorInterface::transChoice
IdentityTranslator::__construct public function Constructor.