当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_Locale::getLocaleToTerritory方法代码示例

本文整理汇总了PHP中Zend_Locale::getLocaleToTerritory方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Locale::getLocaleToTerritory方法的具体用法?PHP Zend_Locale::getLocaleToTerritory怎么用?PHP Zend_Locale::getLocaleToTerritory使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_Locale的用法示例。


在下文中一共展示了Zend_Locale::getLocaleToTerritory方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: convert

 public function convert(Money $money, $target)
 {
     $locale = \Zend_Locale::getLocaleToTerritory($target);
     if (null === $locale) {
         throw new InvalidCountryException(sprintf('Cannot find locale for "%s" country.', $target));
     }
     return $this->converter->convert($money, $locale);
 }
开发者ID:umpirsky,项目名称:locurro,代码行数:8,代码来源:Country.php

示例2: setLanguage

 public function setLanguage($selectedLanguage)
 {
     $sessionHelper = Zend_Controller_Action_HelperBroker::getExistingHelper('session');
     $cacheHelper = Zend_Controller_Action_HelperBroker::getStaticHelper('cache');
     $locale = $sessionHelper->locale;
     $newLocale = Zend_Locale::getLocaleToTerritory($selectedLanguage);
     if ($newLocale !== null) {
         $locale->setLocale($newLocale);
     } else {
         if (Zend_Locale::isLocale($selectedLanguage)) {
             $locale->setLocale($selectedLanguage);
         }
     }
     $sessionHelper->locale = $locale;
     Zend_Registry::get('Zend_Translate')->setLocale($locale);
     $cacheHelper->clean(false, false, array('locale', 'language'));
     return $locale->getLanguage();
 }
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:18,代码来源:Language.php

示例3: 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 When the given locale is no locale or the autodetection fails
  * @return string
  */
 public static function findLocale($locale = null)
 {
     if ($locale === null) {
         require_once 'Zend/Registry.php';
         if (Zend_Registry::isRegistered('Zend_Locale')) {
             $locale = Zend_Registry::get('Zend_Locale');
         }
     }
     if ($locale === null) {
         $locale = new Zend_Locale();
     }
     if (!Zend_Locale::isLocale($locale, true, false)) {
         if (!Zend_Locale::isLocale($locale, false, false)) {
             $locale = Zend_Locale::getLocaleToTerritory($locale);
             if (empty($locale)) {
                 require_once 'Zend/Locale/Exception.php';
                 throw new Zend_Locale_Exception("The locale '{$locale}' is no known locale");
             }
         } else {
             $locale = new Zend_Locale($locale);
         }
     }
     $locale = self::_prepareLocale($locale);
     return $locale;
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:35,代码来源:Locale.php

示例4: _findLanguages

 private function _findLanguages()
 {
     $translate = Zend_Registry::get('Zend_Translate');
     $availLanguages = $translate->getAdapter()->getList();
     $flags = scandir(INSTALL_PATH . DIRECTORY_SEPARATOR . 'system/images/flags/');
     foreach ($flags as $flag) {
         if (!is_file(INSTALL_PATH . DIRECTORY_SEPARATOR . 'system/images/flags/' . $flag)) {
             continue;
         }
         $locale = new Zend_Locale(Zend_Locale::getLocaleToTerritory(substr($flag, 0, 2)));
         $lang = $locale->getLanguage();
         if (array_key_exists($lang, $availLanguages)) {
             $availLanguages[$lang] = 'system/images/flags/' . $flag;
         }
         unset($locale, $lang, $flag);
     }
     return $availLanguages;
 }
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:18,代码来源:IndexController.php

示例5: _initLocale

 protected function _initLocale()
 {
     $config = Application_Model_Mappers_ConfigMapper::getInstance()->getConfig();
     $name = Zend_Locale::getLocaleToTerritory($config['language']);
     if ($name !== null) {
         $locale = new Zend_Locale($name);
     } else {
         $locale = new Zend_Locale();
     }
     $locale->setCache(Zend_Registry::get('cache'));
     Zend_Registry::set('Zend_Locale', $locale);
 }
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:12,代码来源:Bootstrap.php

示例6: _initLocale

 protected function _initLocale()
 {
     $locale = new Zend_Locale();
     $locale_code = Core_Model_Language::DEFAULT_LOCALE;
     $is_installing = $this->getRequest()->isInstalling();
     if ($this->getRequest()->isApplication() && $this->getApplication()->getLocale()) {
         $locale_code = $this->getApplication()->getLocale();
     } else {
         if (!$is_installing) {
             $currency_code = System_Model_Config::getValueFor("system_currency");
             if ($currency_code) {
                 $currency = new Zend_Currency(null, $currency_code);
                 Core_Model_Language::setCurrentCurrency($currency);
             }
             $territory = System_Model_Config::getValueFor("system_territory");
             if ($territory) {
                 $locale_code = $locale->getLocaleToTerritory($territory);
             } else {
                 $locale_code = new Zend_Locale(Core_Model_Language::getCurrentLocale());
             }
         }
     }
     if (!$is_installing) {
         $timezone = System_Model_Config::getValueFor("system_timezone");
         if ($timezone) {
             date_default_timezone_set($timezone);
         }
     }
     $locale->setLocale($locale_code);
     Zend_Registry::set('Zend_Locale', $locale);
 }
开发者ID:bklein01,项目名称:siberian_cms_2,代码行数:31,代码来源:Default.php

示例7: initLocale

 /**
  * Find out locale from the request, settings or session
  * if language choice enabled, try the following:
  *      - REQUEST parameter "lang"
  *      - SESSION parameter "lang"
  *      - Am_App::getUser->lang
  *      - default in App
  *      - en_US
  * else use latter 2
  */
 static function initLocale(Am_Di $di)
 {
     if (defined('AM_ADMIN') && AM_ADMIN) {
         Zend_Locale::setDefault('en_US');
     } else {
         $possibleLang = array();
         if ($di->config->get('lang.display_choice')) {
             $auth = $di->auth;
             $user = $auth->getUserId() ? $auth->getUser() : null;
             if (!empty($_REQUEST['_lang'])) {
                 $possibleLang[] = filterId($_REQUEST['_lang']);
             } elseif (!empty($di->session->lang)) {
                 $possibleLang[] = $di->session->lang;
             } elseif ($user && $user->lang) {
                 $possibleLang[] = $user->lang;
             }
             $br = Zend_Locale::getBrowser();
             arsort($br);
             $possibleLang = array_merge($possibleLang, array_keys($br));
         }
         $possibleLang[] = $di->config->get('lang.default', 'en_US');
         $possibleLang[] = 'en_US';
         // last but not least
         // now choose the best candidate
         $enabledLangs = $di->config->get('lang.enabled', array());
         $checked = array();
         foreach ($possibleLang as $lc) {
             list($lang) = explode('_', $lc, 2);
             if (!in_array($lc, $enabledLangs) && !in_array($lang, $enabledLangs)) {
                 continue;
             }
             if ($lc == $lang) {
                 // we have not got entire locale,guess it
                 if ($lc == 'en') {
                     $lc = 'en_US';
                 } elseif ($lc == 'sv') {
                     $lc = 'sv_SE';
                 } elseif ($lc == 'et') {
                     $lc = 'et_EE';
                 } elseif ($lc == 'vi') {
                     $lc = 'vi_VN';
                 } else {
                     $lc = Zend_Locale::getLocaleToTerritory($lang);
                 }
                 if (!$lc && $lang == 'ko') {
                     $lc = 'ko_KR';
                 }
                 if (!$lc && $lang == 'ja') {
                     $lc = 'ja_JP';
                 }
                 if (!$lc && $lang == 'nb') {
                     $lc = 'nb_NO';
                 }
                 if (!$lc && $lang == 'zh') {
                     $lc = 'zh_Hans';
                 }
                 if (!$lc && $lang == 'el') {
                     $lc = 'el_GR';
                 }
                 if (!$lc && $lang == 'he') {
                     $lc = 'he_IL';
                 }
                 if (!$lc && $lang == 'da') {
                     $lc = 'da_DK';
                 }
                 if (!$lc && $lang == 'cs') {
                     $lc = 'cs_CZ';
                 }
                 if (!$lc && $lang == 'sq') {
                     $lc = 'sq_AL';
                 }
                 if (!$lc) {
                     continue;
                 }
             }
             if (isset($checked[$lc])) {
                 continue;
             }
             $checked[$lc] = true;
             // check if locale file is exists
             $lc = preg_replace('/[^A-Za-z0-9_]/', '', $lc);
             if (!Zend_Locale::isLocale($lc)) {
                 continue;
             }
             Zend_Locale::setDefault($lc);
             // then update user if it was request
             // and set to session
             break;
         }
         if ($di->config->get('lang.display_choice') && !empty($_REQUEST['_lang'])) {
//.........这里部分代码省略.........
开发者ID:grlf,项目名称:eyedock,代码行数:101,代码来源:Locale.php

示例8: getCountriesList

 public static function getCountriesList()
 {
     if (is_null(self::$_countries_list)) {
         self::$_countries_list = array();
         $locale = Zend_Registry::get('Zend_Locale');
         $currency = new Zend_Currency();
         foreach (Zend_Locale::getTranslationList('Territory', null, 2) as $ter => $name) {
             $country_code = Zend_Locale::getLocaleToTerritory($ter);
             if (!is_null($country_code)) {
                 try {
                     $symbol = $currency->getSymbol($country_code);
                     if (!empty($symbol)) {
                         $countries[$country_code] = array('code' => $country_code, 'name' => $name, 'symbol' => $symbol);
                     }
                 } catch (Exception $e) {
                 }
             }
         }
         uasort($countries, 'cmp');
         foreach ($countries as $currency) {
             self::$_countries_list[] = new Core_Model_Default($currency);
         }
     }
     return self::$_countries_list;
 }
开发者ID:bklein01,项目名称:SiberianCMS,代码行数:25,代码来源:Language.php

示例9: _complete

 private function _complete($pageContent, $pageData, $parserOptions)
 {
     $head = '';
     $body = '';
     //parsing seo data
     $seoData = Tools_Seo_Tools::loadSeodata();
     $seoData = $seoData->toArray();
     unset($seoData['id']);
     $seoData = array_map(function ($item) use($pageData, $parserOptions) {
         $parser = new Tools_Content_Parser(null, $pageData, $parserOptions);
         return !empty($item) ? $parser->setContent($item)->parseSimple() : $item;
     }, $seoData);
     preg_match('~(<body[^\\>]*>)(.*)</body>~usi', $pageContent, $body);
     // setting default charset
     if ($this->view->doctype()->isHtml5()) {
         $this->view->headMeta()->setCharset('utf-8');
     }
     $this->_extendHead($pageContent);
     $this->view->placeholder('seo')->exchangeArray($seoData);
     $this->view->websiteUrl = $parserOptions['websiteUrl'];
     $this->view->websiteMainPage = Helpers_Action_Website::DEFAULT_PAGE;
     $this->view->currentTheme = $parserOptions['currentTheme'];
     // building canonical url
     if ('' === ($canonicalScheme = $this->_config->getConfig('canonicalScheme'))) {
         $canonicalScheme = $this->getRequest()->getScheme();
     }
     $this->view->canonicalUrl = $canonicalScheme . '://' . parse_url($parserOptions['websiteUrl'], PHP_URL_HOST) . parse_url($parserOptions['websiteUrl'], PHP_URL_PATH) . ($pageData['url'] !== Helpers_Action_Website::DEFAULT_PAGE ? $pageData['url'] : '');
     $this->view->pageData = $pageData;
     if (Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_ADMINPANEL)) {
         unset($pageData['content']);
         $body[1] .= $this->_helper->admin->renderAdminPanel($this->_helper->session->getCurrentUser()->getRoleId());
     }
     $this->view->bodyTag = $body[1];
     $this->view->content = $body[2];
     $locale = Zend_Locale::getLocaleToTerritory($this->_config->getConfig('language'));
     $this->view->htmlLang = substr($locale, 0, strpos($locale, '_'));
     $this->view->minify = $this->_config->getConfig('enableMinify') && !Tools_Security_Acl::isAllowed(Tools_Security_Acl::RESOURCE_LAYOUT);
 }
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:38,代码来源:IndexController.php

示例10: languageToTerritory

 /**
  * Go from language to territory
  *
  * @param string $lang
  * @return string
  */
 public static function languageToTerritory($lang)
 {
     $config = Zend_Registry::get('config');
     $territory = isset($config->resources->locale->territories->{$lang}) ? $config->resources->locale->territories->{$lang} : Zend_Locale::getLocaleToTerritory($lang);
     return $territory;
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:12,代码来源:I18n.php


注:本文中的Zend_Locale::getLocaleToTerritory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。