當前位置: 首頁>>代碼示例>>PHP>>正文


PHP TTi18n::locale方法代碼示例

本文整理匯總了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;
 }
開發者ID:J-P-Hanafin,項目名稱:TimeTrex-1,代碼行數:41,代碼來源:TTi18n.class.php


注:本文中的TTi18n::locale方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。