lithium\g11n\Locale::cascade()
Cascades a locale.
Usage:
Locale::cascade('en_US');
// returns ['en_US', 'en', 'root']
Locale::cascade('zh_Hans_HK_REVISED');
// returns ['zh_Hans_HK_REVISED', 'zh_Hans_HK', 'zh_Hans', 'zh', 'root']
Parameters
-
string
$locale
A locale in an arbitrary form (i.e.
'en_US'
or'EN-US'
).
Returns
arrayIndexed array of locales (starting with the most specific one).
Links
Source
public static function cascade($locale) {
$locales[] = $locale;
if ($locale === 'root') {
return $locales;
}
$tags = static::decompose($locale);
while (count($tags) > 1) {
array_pop($tags);
$locales[] = static::compose($tags);
}
$locales[] = 'root';
return $locales;
}