Example #1
0
 /**
  * Build a chain of locale objects according to the fallback rule and
  * the available locales.
  * @param \TYPO3\FLOW3\I18n\Locale $locale
  * @return array
  */
 public function getLocaleChain(Locale $locale)
 {
     $fallBackRule = $this->configuration->getFallbackRule();
     $localeChain = array((string) $locale => $locale);
     if ($fallBackRule['strict'] === TRUE) {
         foreach ($fallBackRule['order'] as $localeIdentifier) {
             $localeChain[$localeIdentifier] = new Locale($localeIdentifier);
         }
     } else {
         $locale = $this->findBestMatchingLocale($locale);
         while ($locale !== NULL) {
             $localeChain[(string) $locale] = $locale;
             $locale = $this->getParentLocaleOf($locale);
         }
         foreach ($fallBackRule['order'] as $localeIdentifier) {
             $locale = new Locale($localeIdentifier);
             $locale = $this->findBestMatchingLocale($locale);
             while ($locale !== NULL) {
                 $localeChain[(string) $locale] = $locale;
                 $locale = $this->getParentLocaleOf($locale);
             }
         }
     }
     $locale = $this->configuration->getDefaultLocale();
     $localeChain[(string) $locale] = $locale;
     return $localeChain;
 }