You are here

private function DataCollectorTranslator::collectMessage in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/symfony/translation/DataCollectorTranslator.php \Symfony\Component\Translation\DataCollectorTranslator::collectMessage()

Parameters

string|null $locale:

string|null $domain:

string $id:

string $trans:

2 calls to DataCollectorTranslator::collectMessage()
DataCollectorTranslator::trans in vendor/symfony/translation/DataCollectorTranslator.php
Translates the given message.
DataCollectorTranslator::transChoice in vendor/symfony/translation/DataCollectorTranslator.php
Translates the given choice message by choosing a translation according to a number.

File

vendor/symfony/translation/DataCollectorTranslator.php, line 113

Class

DataCollectorTranslator
@author Abdellatif Ait boudad <a.aitboudad@gmail.com>

Namespace

Symfony\Component\Translation

Code

private function collectMessage($locale, $domain, $id, $translation) {
  if (null === $domain) {
    $domain = 'messages';
  }
  $id = (string) $id;
  $catalogue = $this->translator
    ->getCatalogue($locale);
  $locale = $catalogue
    ->getLocale();
  if ($catalogue
    ->defines($id, $domain)) {
    $state = self::MESSAGE_DEFINED;
  }
  elseif ($catalogue
    ->has($id, $domain)) {
    $state = self::MESSAGE_EQUALS_FALLBACK;
    $fallbackCatalogue = $catalogue
      ->getFallBackCatalogue();
    while ($fallbackCatalogue) {
      if ($fallbackCatalogue
        ->defines($id, $domain)) {
        $locale = $fallbackCatalogue
          ->getLocale();
        break;
      }
      $fallbackCatalogue = $fallbackCatalogue
        ->getFallBackCatalogue();
    }
  }
  else {
    $state = self::MESSAGE_MISSING;
  }
  $this->messages[] = array(
    'locale' => $locale,
    'domain' => $domain,
    'id' => $id,
    'translation' => $translation,
    'state' => $state,
  );
}