예제 #1
0
 /**
  * Get a list of localized timezone names
  *
  * @return array
  */
 public static function getList()
 {
     $xoops = \Xoops::getInstance();
     $locale = \Xoops\Locale::getCurrent();
     $key = ['system', 'lists', 'timezone', $locale];
     //$xoops->cache()->delete($key);
     $timeZones = $xoops->cache()->cacheRead($key, function () {
         $timeZones = array();
         $territories = Territory::getContinentsAndCountries();
         $maxLen = 0;
         $utcDtz = new \DateTimeZone('UTC');
         foreach ($territories as $byContinent) {
             $continent = $byContinent['name'];
             foreach ($byContinent['children'] as $cCode => $cName) {
                 $allZones = $utcDtz->listIdentifiers(\DateTimeZone::PER_COUNTRY, $cCode);
                 foreach ($allZones as $zone) {
                     $maxLen = max(strlen($zone), $maxLen);
                     $name = Calendar::getTimezoneExemplarCity($zone);
                     if (!isset($timeZones[$zone]) && !empty($name)) {
                         $timeZones[$zone] = $continent . '/' . $name;
                     }
                 }
             }
         }
         \XoopsLocale::asort($timeZones);
         $default = array('UTC' => Calendar::getTimezoneNameNoLocationSpecific(new \DateTimeZone('GMT')));
         $timeZones = array_merge($default, $timeZones);
         return $timeZones;
     });
     return $timeZones;
 }
예제 #2
0
파일: Time.php 프로젝트: ming-hai/XoopsCore
 /**
  * Perform any localization required for date picker used in Form\DateSelect
  *
  * @return void
  */
 public static function localizeDatePicker()
 {
     $delimiter = '-';
     $locale = Locale::normalizeLocale(Locale::getCurrent(), $delimiter, false);
     if ('zh_Hant' === Locale::getCurrent()) {
         $locale = 'zh-TW';
     }
     if ($locale === 'zh') {
         $locale = 'zh-CN';
     }
     list($language) = explode($delimiter, $locale);
     $xoops = \Xoops::getInstance();
     $locales = array($locale, $language);
     foreach ($locales as $name) {
         $i18nScript = 'media/jquery/ui/i18n/datepicker-' . $name . '.js';
         if (file_exists($xoops->path($i18nScript))) {
             $xoops->theme()->addBaseScriptAssets($i18nScript);
             return;
         }
     }
 }
예제 #3
0
 /**
  * getLegacyLanguage - return legacy language code for the current locale
  * @return string
  */
 public static function getLegacyLanguage()
 {
     $legacyLanguages = \Xoops\Core\Locale\LegacyCodes::getLegacyName(\Xoops\Locale::getCurrent());
     return reset($legacyLanguages);
 }