You are here

public function Translator::transChoice in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/translation/Translator.php \Symfony\Component\Translation\Translator::transChoice()

Translates the given choice message by choosing a translation according to a number.

Parameters

string $id The message id (may also be an object that can be cast to string):

int $number The number to use to find the indice of the message:

array $parameters An array of parameters for the message:

string|null $domain The domain for the message or null to use the default:

string|null $locale The locale or null to use the default:

Return value

string The translated string

Throws

\InvalidArgumentException If the locale contains invalid characters

Overrides TranslatorInterface::transChoice

File

vendor/symfony/translation/Translator.php, line 215

Class

Translator
Translator.

Namespace

Symfony\Component\Translation

Code

public function transChoice($id, $number, array $parameters = array(), $domain = null, $locale = null) {
  if (null === $domain) {
    $domain = 'messages';
  }
  $id = (string) $id;
  $catalogue = $this
    ->getCatalogue($locale);
  $locale = $catalogue
    ->getLocale();
  while (!$catalogue
    ->defines($id, $domain)) {
    if ($cat = $catalogue
      ->getFallbackCatalogue()) {
      $catalogue = $cat;
      $locale = $catalogue
        ->getLocale();
    }
    else {
      break;
    }
  }
  return strtr($this->selector
    ->choose($catalogue
    ->get($id, $domain), (int) $number, $locale), $parameters);
}