lookup() публичный статический Метод

This method partially implements the lookup matching scheme as described in RFC 4647, section 3.4 and thus does not strictly conform to the specification. Differences to specification: - No support for wildcards in the to-be-matched locales. - No support for locales with private subtags. - No support for a default return value. - Passed locales are required to be in canonical form (i.e. 'ja_JP').
public static lookup ( array $locales, string $locale ) : string
$locales array Locales to match against `$locale`.
$locale string A locale in its canonical form (i.e. `'zh_Hans_HK_REVISED'`).
Результат string The matched locale.
Пример #1
0
 public function testLookup()
 {
     $expected = 'zh_Hans_HK';
     $result = Locale::lookup(array('zh_Hans_REVISED', 'zh_Hans_HK', 'zh', 'zh_Hans'), 'zh_Hans_HK_REVISED');
     $this->assertEqual($expected, $result);
     $expected = 'zh_Hans_HK';
     $result = Locale::lookup(array('zh', 'zh_Hans_REVISED', 'zh_Hans_HK', 'zh_Hans'), 'zh_Hans_HK_REVISED');
     $this->assertEqual($expected, $result);
 }
Пример #2
0
 public function testLookup()
 {
     $result = Locale::lookup(array('zh_Hans_REVISED', 'zh_Hans_HK', 'zh', 'zh_Hans'), 'zh_Hans_HK_REVISED');
     $this->assertEqual('zh_Hans_HK', $result);
     $result = Locale::lookup(array('zh', 'zh_Hans_REVISED', 'zh_Hans_HK', 'zh_Hans'), 'zh_Hans_HK_REVISED');
     $this->assertEqual('zh_Hans_HK', $result);
     $result = Locale::lookup(array('en', 'en_UK', 'en_US', 'es', 'es_AR'), 'en');
     $this->assertEqual('en', $result);
     $result = Locale::lookup(array('en', 'en_UK', 'en_US', 'es', 'es_AR'), 'en_UK');
     $this->assertEqual('en_UK', $result);
     $result = Locale::lookup(array('en', 'en_UK', 'en_US', 'es', 'es_AR'), 'es_ES');
     $this->assertEqual('es', $result);
     $result = Locale::lookup(array('en', 'en_UK', 'en_US', 'es_AR'), 'es_ES');
     $this->assertEqual('es_AR', $result);
 }