public static function lookup($locales, $locale) {
		$tags = static::decompose($locale);

		while (($count = count($tags)) > 0) {
			if (($key = array_search(static::compose($tags), $locales)) !== false) {
				return $locales[$key];
			}
			if ($count === 1) {
				foreach ($locales as $current) {
					if (strpos($current, current($tags) . '_') === 0) {
						return $current;
					}
				}
			}
			if (($key = array_search(static::compose($tags), $locales)) !== false) {
				return $locales[$key];
			}
			array_pop($tags);
		}
	}