findBestMatchingLocale() public method

Returns Locale object which represents one of locales installed and which is most similar to the "template" Locale object given as parameter.
public findBestMatchingLocale ( Locale $locale ) : mixed
$locale Locale The "template" locale to be matched
return mixed Existing Locale instance on success, NULL on failure
 /**
  * @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 I18n\Locale('pl_PL_DVORAK')));
     $this->assertNull($this->localeCollection->findBestMatchingLocale(new I18n\Locale('sv')));
 }
 /**
  * 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 Locale $locale The template Locale object
  * @return Locale Best-matching existing Locale instance
  * @api
  */
 public function detectLocaleFromTemplateLocale(Locale $locale)
 {
     $bestMatchingLocale = $this->localeCollection->findBestMatchingLocale($locale);
     if ($bestMatchingLocale !== null) {
         return $bestMatchingLocale;
     }
     return $this->localizationService->getConfiguration()->getDefaultLocale();
 }
 /**
  * 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 Flow installation.
  *
  * @param Locale $locale The "template" Locale to be matched
  * @return mixed Existing Locale instance on success, NULL on failure
  * @api
  */
 public function findBestMatchingLocale(Locale $locale)
 {
     return $this->localeCollection->findBestMatchingLocale($locale);
 }