Пример #1
0
 /**
  * @test
  */
 public function modelIsReturnedCorrectlyForLocaleImplicatingChaining()
 {
     $localeImplementingChaining = new \TYPO3\FLOW3\I18n\Locale('de_DE');
     $cldrModel = $this->cldrRepository->getModelForLocale($localeImplementingChaining);
     $this->assertAttributeContains(\TYPO3\FLOW3\Utility\Files::concatenatePaths(array($this->cldrBasePath, 'main/root.xml')), 'sourcePaths', $cldrModel);
     $this->assertAttributeContains(\TYPO3\FLOW3\Utility\Files::concatenatePaths(array($this->cldrBasePath, 'main/de_DE.xml')), 'sourcePaths', $cldrModel);
     $this->assertAttributeContains(\TYPO3\FLOW3\Utility\Files::concatenatePaths(array($this->cldrBasePath, 'main/de.xml')), 'sourcePaths', $cldrModel);
 }
Пример #2
0
 /**
  * @test
  */
 public function modelIsReturnedCorrectlyForGroupOfFiles()
 {
     mkdir('vfs://Foo/Directory');
     file_put_contents('vfs://Foo/Directory/en.xml', '');
     $result = $this->repository->getModelForLocale($this->dummyLocale, 'Directory');
     $this->assertAttributeContains('vfs://Foo/Directory/root.xml', 'sourcePaths', $result);
     $this->assertAttributeContains('vfs://Foo/Directory/en.xml', 'sourcePaths', $result);
     $result = $this->repository->getModelForLocale($this->dummyLocale, 'NoSuchDirectory');
     $this->assertEquals(NULL, $result);
 }
Пример #3
0
 /**
  * Returns symbols array for provided locale.
  *
  * Symbols are elements defined in tag symbols from CLDR. They define
  * localized versions of various number-related elements, like decimal
  * separator, group separator or minus sign.
  *
  * Symbols arrays for every requested locale are cached.
  *
  * @param \TYPO3\FLOW3\I18n\Locale $locale
  * @return array Symbols array
  */
 public function getLocalizedSymbolsForLocale(\TYPO3\FLOW3\I18n\Locale $locale)
 {
     if (isset($this->localizedSymbols[(string) $locale])) {
         return $this->localizedSymbols[(string) $locale];
     }
     $model = $this->cldrRepository->getModelForLocale($locale);
     return $this->localizedSymbols[(string) $locale] = $model->getRawArray('numbers/symbols');
 }
Пример #4
0
 /**
  * Returns literals array for locale provided.
  *
  * If array was not generated earlier, it will be generated and cached.
  *
  * @param \TYPO3\FLOW3\I18n\Locale $locale
  * @return array An array with localized literals
  */
 public function getLocalizedLiteralsForLocale(\TYPO3\FLOW3\I18n\Locale $locale)
 {
     if (isset($this->localizedLiterals[(string) $locale])) {
         return $this->localizedLiterals[(string) $locale];
     }
     $model = $this->cldrRepository->getModelForLocale($locale);
     $localizedLiterals['months'] = $this->parseLocalizedLiterals($model, 'month');
     $localizedLiterals['days'] = $this->parseLocalizedLiterals($model, 'day');
     $localizedLiterals['quarters'] = $this->parseLocalizedLiterals($model, 'quarter');
     $localizedLiterals['dayPeriods'] = $this->parseLocalizedLiterals($model, 'dayPeriod');
     $localizedLiterals['eras'] = $this->parseLocalizedEras($model);
     return $this->localizedLiterals[(string) $locale] = $localizedLiterals;
 }
Пример #5
0
 /**
  * Generates an internal representation of plural rules which can be found
  * in plurals.xml CLDR file.
  *
  * The properties $rulesets and $rulesetsIndices should be empty before
  * running this method.
  *
  * @return void
  * @see \TYPO3\FLOW3\I18n\Cldr\Reader\PluralsReader::$rulesets
  */
 protected function generateRulesets()
 {
     $model = $this->cldrRepository->getModel('supplemental/plurals');
     $pluralRulesSet = $model->getRawArray('plurals');
     $index = 0;
     foreach ($pluralRulesSet as $pluralRulesNodeString => $pluralRules) {
         $localeLanguages = $model->getAttributeValue($pluralRulesNodeString, 'locales');
         foreach (explode(' ', $localeLanguages) as $localeLanguage) {
             $this->rulesetsIndices[$localeLanguage] = $index;
         }
         if (is_array($pluralRules)) {
             $ruleset = array();
             foreach ($pluralRules as $pluralRuleNodeString => $pluralRule) {
                 $pluralForm = $model->getAttributeValue($pluralRuleNodeString, 'count');
                 $ruleset[$pluralForm] = $this->parseRule($pluralRule);
             }
             foreach (explode(' ', $localeLanguages) as $localeLanguage) {
                 $this->rulesets[$localeLanguage][$index] = $ruleset;
             }
         }
         ++$index;
     }
 }