本文整理匯總了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;
}