lithium\g11n\Locale::cascade()

public static method

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

array

Indexed array of locales (starting with the most specific one).

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;
	}