本文整理汇总了PHP中Zend\Locale\Locale::getLocaleToTerritory方法的典型用法代码示例。如果您正苦于以下问题:PHP Locale::getLocaleToTerritory方法的具体用法?PHP Locale::getLocaleToTerritory怎么用?PHP Locale::getLocaleToTerritory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Locale\Locale
的用法示例。
在下文中一共展示了Locale::getLocaleToTerritory方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findLocale
/**
* Finds the proper locale based on the input
* Checks if it exists, degrades it when necessary
* Detects registry locale and when all fails tries to detect a automatic locale
* Returns the found locale as string
*
* @param string $locale
* @throws \Zend\Locale\Exception\InvalidArgumentException When the given locale is no locale or the autodetection fails
* @return string
*/
public static function findLocale($locale = null)
{
if ($locale === null) {
if (Registry::isRegistered('Zend_Locale')) {
$locale = Registry::get('Zend_Locale');
}
}
if ($locale === null) {
$locale = new Locale();
}
if (!Locale::isLocale($locale, true)) {
if (!Locale::isLocale($locale, false)) {
$locale = Locale::getLocaleToTerritory($locale);
if (empty($locale)) {
throw new Exception\InvalidArgumentException("The locale '{$locale}' is no known locale");
}
} else {
$locale = new self($locale);
}
}
$locale = self::_prepareLocale($locale);
return $locale;
}