/**
  * @test
  */
 public function modelIsReturnedCorrectlyForLocaleImplicatingChaining()
 {
     $localeImplementingChaining = new \TYPO3\Flow\I18n\Locale('de_DE');
     $cldrModel = $this->cldrRepository->getModelForLocale($localeImplementingChaining);
     $this->assertAttributeContains(\TYPO3\Flow\Utility\Files::concatenatePaths(array($this->cldrBasePath, 'main/root.xml')), 'sourcePaths', $cldrModel);
     $this->assertAttributeContains(\TYPO3\Flow\Utility\Files::concatenatePaths(array($this->cldrBasePath, 'main/de_DE.xml')), 'sourcePaths', $cldrModel);
     $this->assertAttributeContains(\TYPO3\Flow\Utility\Files::concatenatePaths(array($this->cldrBasePath, 'main/de.xml')), 'sourcePaths', $cldrModel);
 }
 /**
  * @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);
 }
 /**
  * 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\Flow\I18n\Locale $locale
  * @return array Symbols array
  */
 public function getLocalizedSymbolsForLocale(\TYPO3\Flow\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');
 }
 /**
  * Returns literals array for locale provided.
  *
  * If array was not generated earlier, it will be generated and cached.
  *
  * @param \TYPO3\Flow\I18n\Locale $locale
  * @return array An array with localized literals
  */
 public function getLocalizedLiteralsForLocale(\TYPO3\Flow\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;
 }
Ejemplo n.º 5
0
 /**
  * Get an array of all values in the CLDR where the key is the type attribute
  *
  * @param string $path The xpath to select values from
  * @return array|boolean
  */
 protected function getKeyValues($path)
 {
     $defaultLocale = $this->detector->detectLocaleFromLocaleTag('en');
     $model = $this->cldrRepository->getModelForLocale($defaultLocale);
     $data = $model->getRawArray($path);
     if ($data === FALSE) {
         return FALSE;
     }
     $filteredData = array();
     foreach ($data as $nodeString => $children) {
         if (CldrModel::getAttributeValue($nodeString, 'alt') === FALSE) {
             $key = CldrModel::getAttributeValue($nodeString, 'type');
             $filteredData[$key] = $children;
         }
     }
     return $filteredData;
 }