本文整理汇总了PHP中TTi18n::locale方法的典型用法代码示例。如果您正苦于以下问题:PHP TTi18n::locale方法的具体用法?PHP TTi18n::locale怎么用?PHP TTi18n::locale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TTi18n
的用法示例。
在下文中一共展示了TTi18n::locale方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setLocale
public static function setLocale($locale_arg = NULL, $category = LC_ALL)
{
Debug::Text('Generated/Passed In Locale: ' . $locale_arg, __FILE__, __LINE__, __METHOD__, 10);
$locales = self::generateLocale($locale_arg);
$locale = self::tryLocale($locales);
unset($locales);
Debug::Text('Attempting to set Locale(s) to: ' . $locale . ' Category: ' . $category . ' Current Locale: ' . self::getLocale(), __FILE__, __LINE__, __METHOD__, 10);
if ($locale != self::getLocale() and in_array($category, array(LC_ALL, LC_MONETARY, LC_NUMERIC))) {
Debug::Text('Setting currency/numeric Locale to: ' . $locale, __FILE__, __LINE__, __METHOD__, 10);
//if ( self::getLocaleHandler()->setLocale( $locale, $category ) != $locale ) {
//Setting the locale in Windows can cause the locale names to not match at all, so check for FALSE
if (self::getLocaleHandler()->setLocale($locale, $category) == FALSE) {
Debug::Text('Failed setting currency/numeric locale: ' . $locale, __FILE__, __LINE__, __METHOD__, 10);
}
}
if ($locale != self::getLocale() and in_array($category, array(LC_ALL, LC_MESSAGES))) {
// We normalize locales to a single "standard" locale for each lang
// to avoid having to maintain lots of mostly duplicate translation files
// for each lang/country combination.
$normal_locale = self::_normalizeLocale($locale);
Debug::Text('Setting translator to normalized locale: ' . $normal_locale, __FILE__, __LINE__, __METHOD__, 10);
if (self::getTranslationHandler()->setLang($normal_locale) === FALSE) {
//Fall back on non-normalized locale
Debug::Text('Failed setting translator normalized locale: ' . $normal_locale . ' Falling back to: ' . $locale, __FILE__, __LINE__, __METHOD__, 10);
if (self::getTranslationHandler()->setLang($locale) === FALSE) {
Debug::Text('Failed setting translator locale: ' . $locale, __FILE__, __LINE__, __METHOD__, 10);
return FALSE;
}
}
}
self::$locale = $locale;
self::$language = substr($locale, 0, 2);
//save language here to avoid becoming out of sync.
if ($category == LC_ALL) {
if (self::$master_locale == NULL) {
self::$master_locale = $locale;
}
}
Debug::Text('Set Master Locale To: ' . $locale, __FILE__, __LINE__, __METHOD__, 10);
return TRUE;
}