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


PHP Zend_Locale::getAlias方法代碼示例

本文整理匯總了PHP中Zend_Locale::getAlias方法的典型用法代碼示例。如果您正苦於以下問題:PHP Zend_Locale::getAlias方法的具體用法?PHP Zend_Locale::getAlias怎麽用?PHP Zend_Locale::getAlias使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend_Locale的用法示例。


在下文中一共展示了Zend_Locale::getAlias方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: _getOptionLocales

 /**
  * Get options array for locale dropdown
  *
  * @param   bool $translatedName translation flag
  * @return  array
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function _getOptionLocales($translatedName = false)
 {
     $options = [];
     $locales = $this->_localeResolver->getLocale()->getLocaleList();
     $languages = $this->_localeResolver->getLocale()->getTranslationList('language', $this->_localeResolver->getLocale());
     $countries = $this->_localeResolver->getLocale()->getTranslationList('territory', $this->_localeResolver->getLocale(), 2);
     //Zend locale codes for internal allowed locale codes
     $allowed = $this->_config->getAllowedLocales();
     $allowedAliases = [];
     foreach ($allowed as $code) {
         $allowedAliases[\Zend_Locale::getAlias($code)] = $code;
     }
     //Process translating to internal locale codes from Zend locale codes
     $processedLocales = [];
     foreach ($locales as $code => $active) {
         if (array_key_exists($code, $allowedAliases)) {
             $processedLocales[$allowedAliases[$code]] = $active;
         } else {
             $processedLocales[$code] = $active;
         }
     }
     foreach (array_keys($processedLocales) as $code) {
         if (strstr($code, '_')) {
             if (!in_array($code, $allowed)) {
                 continue;
             }
             $data = explode('_', $code);
             if (!isset($languages[$data[0]]) || !isset($countries[$data[1]])) {
                 continue;
             }
             if ($translatedName) {
                 $label = ucwords($this->_localeResolver->getLocale()->getTranslation($data[0], 'language', $code)) . ' (' . $this->_localeResolver->getLocale()->getTranslation($data[1], 'country', $code) . ') / ' . $languages[$data[0]] . ' (' . $countries[$data[1]] . ')';
             } else {
                 $label = $languages[$data[0]] . ' (' . $countries[$data[1]] . ')';
             }
             $options[] = ['value' => $code, 'label' => $label];
         }
     }
     return $this->_sortOptionArray($options);
 }
開發者ID:ViniciusAugusto,項目名稱:magento2,代碼行數:47,代碼來源:Lists.php

示例2: _checkLocale

 /**
  * Internal function for checking the locale
  *
  * @param  string|Zend_Locale $locale Locale to check
  * @return string
  * @throws Zend_Locale_Exception
  */
 private static function _checkLocale($locale)
 {
     if (empty($locale)) {
         $locale = new Zend_Locale();
     }
     if (!Zend_Locale::isLocale((string) $locale, null, false)) {
         // require_once 'Zend/Locale/Exception.php';
         throw new Zend_Locale_Exception("Locale (" . (string) $locale . ") is a unknown locale");
     }
     if (Zend_Locale::isAlias($locale)) {
         // Return a valid CLDR locale so that the XML file can be loaded.
         return Zend_Locale::getAlias($locale);
     }
     return (string) $locale;
 }
開發者ID:sadikeser,項目名稱:tickets,代碼行數:22,代碼來源:Data.php

示例3: testAliases

 /**
  * Test that locale names that have been dropped from CLDR continue to
  * work.
  */
 public function testAliases()
 {
     $locale = new Zend_Locale('zh_CN');
     $this->assertEquals(true, $locale->isLocale('zh_CN'));
     $this->assertEquals('zh', $locale->getLanguage());
     $this->assertEquals('CN', $locale->getRegion());
     $this->assertEquals(true, Zend_Locale::isAlias($locale));
     $this->assertEquals(true, Zend_Locale::isAlias('zh_CN'));
     $this->assertEquals('zh_Hans_CN', Zend_Locale::getAlias('zh_CN'));
     $locale = new Zend_Locale('zh_Hans_CN');
     $this->assertEquals(true, $locale->isLocale('zh_Hans_CN'));
     $this->assertEquals('zh', $locale->getLanguage());
     $this->assertEquals('CN', $locale->getRegion());
     $this->assertEquals(false, Zend_Locale::isAlias('zh_Hans_CN'));
     $this->assertEquals('zh_Hans_CN', Zend_Locale::getAlias('zh_Hans_CN'));
 }
開發者ID:crodriguezn,項目名稱:crossfit-milagro,代碼行數:20,代碼來源:LocaleTest.php

示例4: getLabels

 /**
  * Get all labels of the attributes
  *
  * @return string[] with 'locale' => 'label'
  */
 public function getLabels()
 {
     if (isset($this->_labels)) {
         return $this->_labels;
     }
     $labelsNode = $this->_xmlElement->{'labels'};
     $labels = [];
     if ($labelsNode->count() > 0) {
         foreach ($labelsNode->children() as $labelNode) {
             /** @var SimpleXmlElement $labelNode */
             $locale = $labelNode->getName();
             if (Zend_Locale::isAlias($locale)) {
                 $locale = Zend_Locale::getAlias($locale);
             }
             $label = (string) $labelNode;
             $labels[$locale] = $label;
         }
     }
     $this->_labels = $labels;
     return $labels;
 }
開發者ID:aoepeople,項目名稱:aoe_attributeconfigurator,代碼行數:26,代碼來源:Attribute.php


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