Example #1
0
 /**
  * @test
  */
 public function bestMatchingLocalesAreFoundCorrectly()
 {
     foreach ($this->locales as $locale) {
         $this->localeCollection->addLocale($locale);
     }
     $this->assertEquals($this->locales[1], $this->localeCollection->findBestMatchingLocale($this->locales[1]));
     $this->assertEquals($this->locales[1], $this->localeCollection->findBestMatchingLocale(new \TYPO3\FLOW3\I18n\Locale('pl_PL_DVORAK')));
     $this->assertNull($this->localeCollection->findBestMatchingLocale(new \TYPO3\FLOW3\I18n\Locale('sv')));
 }
Example #2
0
 /**
  * Returns best-matching Locale object based on the template Locale object
  * provided as parameter. System default locale will be returned if no
  * successful matches were done.
  *
  * @param \TYPO3\FLOW3\I18n\Locale $locale The template Locale object
  * @return \TYPO3\FLOW3\I18n\Locale Best-matching existing Locale instance
  * @api
  */
 public function detectLocaleFromTemplateLocale(\TYPO3\FLOW3\I18n\Locale $locale)
 {
     $bestMatchingLocale = $this->localeCollection->findBestMatchingLocale($locale);
     if ($bestMatchingLocale !== NULL) {
         return $bestMatchingLocale;
     }
     return $this->localizationService->getConfiguration()->getDefaultLocale();
 }
Example #3
0
 /**
  * Returns Locale object which is the most similar to the "template" Locale
  * object given as parameter, from the collection of locales available in
  * the current FLOW3 installation.
  *
  * @param \TYPO3\FLOW3\I18n\Locale $locale The "template" Locale to be matched
  * @return mixed Existing \TYPO3\FLOW3\I18n\Locale instance on success, NULL on failure
  * @api
  */
 public function findBestMatchingLocale(\TYPO3\FLOW3\I18n\Locale $locale)
 {
     return $this->localeCollection->findBestMatchingLocale($locale);
 }