canonicalize() public static method

Canonicalize the given locale.
public static canonicalize ( string $locale = null ) : string
$locale string The locale.
return string The canonicalized locale.
 /**
  * @covers ::canonicalize
  */
 public function testCanonicalize()
 {
     $locale = LocaleHelper::canonicalize('BS_cyrl-ba');
     $this->assertEquals('bs-Cyrl-BA', $locale);
     $locale = LocaleHelper::canonicalize(null);
     $this->assertEquals(null, $locale);
 }
 /**
  * {@inheritdoc}
  */
 public function getList($locale = null)
 {
     if ($this->countryRepository) {
         $countryNames = $this->countryRepository->getList($locale);
     } else {
         $locale = LocaleHelper::canonicalize($locale);
         // symfony/intl uses underscores.
         $locale = str_replace('-', '_', $locale);
         $countryNames = $this->regionBundle->getCountryNames($locale);
     }
     return $countryNames;
 }
Beispiel #3
0
/**
 * Processes the locale string.
 */
function process_locale($locale)
{
    // Be more precise when it comes to Chinese Simplified.
    if ($locale == 'zh') {
        $locale = 'zh-hans';
    }
    return LocaleHelper::canonicalize($locale);
}