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


PHP Zend_Locale::isLocale方法代码示例

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


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

示例1: indexAction

 public function indexAction()
 {
     if ($this->getRequest()->getParam('garbage')) {
         $this->redirect('');
     }
     $translator = Zend_Registry::get('Zend_Translate');
     if (!$this->getRequest()->isPost()) {
         if (Zend_Session::sessionExists()) {
             $namespace = $this->_session->getNamespace();
             if (isset($_SESSION[$namespace])) {
                 unset($_SESSION[$namespace]);
             }
             $translator->setLocale('en');
             Zend_Registry::set('Zend_Translate', $translator);
             Zend_Session::regenerateId();
         }
     } else {
         $lang = $this->getRequest()->getParam('lang');
         if ($lang && Zend_Locale::isLocale($lang)) {
             $this->_session->locale->setLocale($lang);
             if ($translator->getLocale() !== $lang) {
                 $translator->setLocale($lang);
                 Zend_Registry::set('Zend_Translate', $translator);
             }
             $this->_session->nextStep = 1;
         }
         if ($this->_session->nextStep !== null) {
             return $this->forward('step' . $this->_session->nextStep);
         }
     }
     $this->forward('step1');
 }
开发者ID:PavloKovalov,项目名称:seotoaster,代码行数:32,代码来源:IndexController.php

示例2: translate

 /**
  * Translate a message
  * You can give multiple params or an array of params.
  * If you want to output another locale just set it as last single parameter
  * Example 1: translate('%1\$s + %2\$s', $value1, $value2, $locale);
  * Example 2: translate('%1\$s + %2\$s', array($value1, $value2), $locale); 
  *
  * @param string           $messageid
  * @return string  Translated message
  */
 public function translate($messageid = null)
 {
     if ($this->translate === null) {
         require_once 'Zend/Registry.php';
         if (!Zend_Registry::isRegistered('Zend_Translate')) {
             if (empty($messageid)) {
                 return $this;
             } else {
                 return $messageid;
             }
         } else {
             $this->translate = Zend_Registry::get('Zend_Translate');
         }
     }
     $options = func_get_args();
     array_shift($options);
     $count = count($options);
     $locale = null;
     if ($count > 0) {
         if (Zend_Locale::isLocale($options[$count - 1])) {
             $locale = array_pop($options);
         }
     }
     if (count($options) == 1 and is_array($options[0])) {
         $options = $options[0];
     }
     $message = $this->translate->translate($messageid, $locale);
     return vsprintf($message, $options);
 }
开发者ID:dalinhuang,项目名称:popo,代码行数:39,代码来源:Translate.php

示例3: routeShutdown

 public function routeShutdown(Zend_Controller_Request_Abstract $request)
 {
     $translate = Zend_Registry::get('Zend_Translate');
     $locale = Zend_Registry::get('Zend_Locale');
     $languages = Zend_Registry::get('languages');
     $front = Zend_Controller_Front::getInstance();
     $router = $front->getRouter();
     $view = Zend_Layout::getMvcInstance()->getView();
     //$view->route = '';
     if ($language = strtolower($request->getParam('language'))) {
         if ($language != $locale->getLanguage($translate->getLocale()) && Zend_Locale::isLocale($language)) {
             try {
                 $translate->addTranslation(APPLICATION_PATH . '/../data/locales/' . $language . '.php', $language);
                 if ($translate->isAvailable($language)) {
                     $locale->setLocale($languages[$language]);
                     $router->setGlobalParam('language', $language);
                     Zend_Registry::set('Zend_Translate', $translate);
                     Zend_Registry::set('Zend_Locale', $locale);
                     //$view->route .= '_language';
                 }
             } catch (Exception $e) {
             }
         }
     }
     $view->route = $router->getCurrentRouteName();
     /*        
     echo $router->getCurrentRouteName();
     echo '
       <h3>Request Parameters:</h3>
       <pre> ' . var_export($request->getParams(), true) . '
       </pre>
     '; 
     //die();
     */
 }
开发者ID:ankuradhey,项目名称:laundry,代码行数:35,代码来源:Init.php

示例4: translate

 /**
  * Translate a message
  * You can give multiple params or an array of params.
  * If you want to output another locale just set it as last single parameter
  * Example 1: translate('%1\$s + %2\$s', $value1, $value2, $locale);
  * Example 2: translate('%1\$s + %2\$s', array($value1, $value2), $locale);
  *
  * @param  string $messageid Id of the message to be translated
  * @return string|Zend_View_Helper_Translate Translated message
  */
 public function translate($messageid = null)
 {
     if ($messageid === null) {
         return $this;
     }
     $translate = $this->getTranslator();
     $options = func_get_args();
     array_shift($options);
     $count = count($options);
     $locale = null;
     if ($count > 0) {
         if (Zend_Locale::isLocale($options[$count - 1], null, false) !== false) {
             $locale = array_pop($options);
         }
     }
     if (count($options) === 1 and is_array($options[0]) === true) {
         $options = $options[0];
     }
     if ($translate !== null) {
         $messageid = $translate->translate($messageid, $locale);
     }
     if (count($options) === 0) {
         return $messageid;
     }
     return vsprintf($messageid, $options);
 }
开发者ID:fredcido,项目名称:cenbrap,代码行数:36,代码来源:Translate.php

示例5: startLocale

 protected function startLocale()
 {
     require_once "Zend/Translate.php";
     // silenciando strict até arrumar zend_locale
     date_default_timezone_set("America/Sao_Paulo");
     $i18n = new Zend_Translate('gettext', $this->config->system->path->base . '/lang/pt_BR.mo', 'pt_BR');
     Zend_Registry::set('i18n', $i18n);
     $translation_files = $this->config->system->path->base . "/lang/";
     foreach (scandir($translation_files) as $filename) {
         // Todos os arquivos .php devem ser classes de descrição de modulos
         if (preg_match("/.*\\.mo\$/", $filename)) {
             $translation_id = basename($filename, '.mo');
             if ($translation_id != "pt_BR") {
                 $i18n->addTranslation($translation_files . "/{$filename}", $translation_id);
             }
         }
     }
     require_once "Zend/Locale.php";
     if (Zend_Locale::isLocale($this->config->system->locale)) {
         $locale = $this->config->system->locale;
     } else {
         $locale = "pt_BR";
     }
     Zend_Registry::set('Zend_Locale', new Zend_Locale($locale));
     Zend_Locale::setDefault($locale);
     Zend_Locale_Format::setOptions(array("locale" => $locale));
     $i18n->setLocale($locale);
     Zend_Registry::set("Zend_Translate", $i18n);
     $zend_validate_translator = new Zend_Translate_Adapter_Array($this->config->system->path->base . "/lang/Zend_Validate/{$locale}/Zend_Validate.php", $locale);
     Zend_Validate_Abstract::setDefaultTranslator($zend_validate_translator);
 }
开发者ID:rootzig,项目名称:SNEP,代码行数:31,代码来源:Bootstrap.php

示例6: __construct

 /**
  * Zend_Measure_Abstract is an abstract class for the different measurement types
  *
  * @param  $value  mixed  - Value as string, integer, real or float
  * @param  $type   type   - OPTIONAL a Zend_Measure_Area Type
  * @param  $locale locale - OPTIONAL a Zend_Locale Type
  * @throws Zend_Measure_Exception
  */
 public function __construct($value, $type, $locale = null)
 {
     if (Zend_Locale::isLocale($type)) {
         $locale = $type;
         $type = null;
     }
     if ($locale === null) {
         $locale = new Zend_Locale();
     }
     if ($locale instanceof Zend_Locale) {
         $locale = $locale->toString();
     }
     if (!($this->_Locale = Zend_Locale::isLocale($locale, true))) {
         require_once 'Zend/Measure/Exception.php';
         throw new Zend_Measure_Exception("Language ({$locale}) is unknown");
     }
     $this->_Locale = $locale;
     if ($type === null) {
         $type = $this->_UNITS['STANDARD'];
     }
     if (!array_key_exists($type, $this->_UNITS)) {
         require_once 'Zend/Measure/Exception.php';
         throw new Zend_Measure_Exception("Type ({$type}) is unknown");
     }
     $this->setValue($value, $type, $this->_Locale);
 }
开发者ID:adnanali,项目名称:munch,代码行数:34,代码来源:Number.php

示例7: t

 /**
  * Translate a message
  * You can give multiple params or an array of params.
  * If you want to output another locale just set it as last single parameter
  * Example 1: translate('%1\$s + %2\$s', $value1, $value2, $locale);
  * Example 2: translate('%1\$s + %2\$s', array($value1, $value2), $locale);
  *
  * @param  string $messageid Id of the message to be translated
  * @return string|Zend_View_Helper_Translate Translated message
  */
 public function t($messageid)
 {
     if ($messageid === null) {
         return $this;
     }
     if (Zend_Registry::isRegistered('Zend_Translate')) {
         $translate = Zend_Registry::get('Zend_Translate');
     } else {
         Zend_Registry::get('Bootstrap')->bootstrap('Translator');
     }
     $options = func_get_args();
     array_shift($options);
     $count = count($options);
     $locale = null;
     if ($count > 0) {
         if (Zend_Locale::isLocale($options[$count - 1], null, false) !== false) {
             $locale = array_pop($options);
         }
     }
     if (count($options) === 1 and is_array($options[0]) === true) {
         $options = $options[0];
     }
     if ($translate !== null) {
         $messageid = $translate->translate($messageid, $locale);
     }
     if (count($options) === 0) {
         return $messageid;
     }
     return vsprintf($messageid, $options);
 }
开发者ID:nic162,项目名称:Zend-Framework-Skeleton,代码行数:40,代码来源:T.php

示例8: translate

 /**
  * Translate a message
  * You can give an array of params.
  * If you want to output another locale just set it as last single parameter
  * Example 1: translate('Some text', $locale);
  * Example 2: translate('%key1% + %key2%', array('key1' => $value1, 'key2' => $value2), $locale);
  *
  * @param  string $messageid Id of the message to be translated
  * @param  array  $values Values for translation placeholders as assoc array
  * @return string|Zend_View_Helper_Translate Translated message
  */
 public function translate($messageid = null, $values = array())
 {
     if ($messageid === null) {
         return $this;
     }
     $translate = $this->getTranslator();
     $options = func_get_args();
     array_shift($options);
     $count = count($options);
     $locale = null;
     if ($count > 0) {
         if (Zend_Locale::isLocale($options[$count - 1], null, false) !== false) {
             $locale = array_pop($options);
         }
     }
     if ($translate !== null) {
         $messageid = $translate->translate($messageid, $locale);
     }
     if (count($values) === 0) {
         return $messageid;
     }
     if (count($values)) {
         foreach ($values as $key => $value) {
             $messageid = str_replace('%' . $key . '%', $value, $messageid);
         }
     }
     return $messageid;
 }
开发者ID:KasaiDot,项目名称:FansubCMS,代码行数:39,代码来源:Translate.php

示例9: testIsLocale

 /**
  * Tests if the given language is really a language
  */
 public function testIsLocale()
 {
     foreach ($this->_languages as $lang) {
         if (!Zend_Locale::isLocale($lang, true, false)) {
             $this->fail("Language directory '{$lang}' not a valid locale");
         }
     }
 }
开发者ID:heiglandreas,项目名称:zf2,代码行数:11,代码来源:Zend_ValidateTest.php

示例10: __construct

 /**
  * Constructor
  * @param array $options
  */
 public function __construct($options = array())
 {
     if (Zend_Locale::isLocale($options)) {
         $this->_locale = $options;
     } else {
         if (Zend_Registry::isRegistered('Zend_Locale')) {
             $this->_locale = Zend_Registry::get('Zend_Locale');
         }
     }
 }
开发者ID:ocpyosep78,项目名称:Booking,代码行数:14,代码来源:Currency.php

示例11: _initTranslate

 /**
  * Referência:
  * http://www.codeforest.net/multilanguage-support-in-zend-framework
  */
 protected function _initTranslate()
 {
     $locale = new Zend_Locale();
     if (!Zend_Locale::isLocale($locale, TRUE, FALSE)) {
         if (!Zend_Locale::isLocale($locale, FALSE, FALSE)) {
             throw new Zend_Locale_Exception("The locale '{$locale}' is no known locale");
         }
         $locale = new Zend_Locale($locale);
     }
     //$locale = "pt_BR";
     $translatorArray = new Zend_Translate(array('adapter' => 'array', 'content' => APPLICATION_PATH . '/../resources/languages', 'locale' => $locale, 'scan' => Zend_Translate::LOCALE_DIRECTORY));
     $translate = new Zend_Translate('gettext', APPLICATION_PATH . "/langs/", $locale, array('scan' => Zend_Translate::LOCALE_DIRECTORY));
     $translate->addTranslation($translatorArray);
     $registry = Zend_Registry::getInstance();
     $registry->set('Zend_Translate', $translate);
     Zend_Validate_Abstract::setDefaultTranslator($translate);
     Zend_Form::setDefaultTranslator($translate);
 }
开发者ID:jovanepires,项目名称:sige,代码行数:22,代码来源:Bootstrap.php

示例12: 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

示例13: currency

 /**
  * Output a formatted currency
  *
  * @param  integer|float                    $value    Currency value to output
  * @param  string|Zend_Locale|Zend_Currency $currency OPTIONAL Currency to use for this call
  * @return string Formatted currency
  */
 public function currency($value = null, $currency = null)
 {
     if ($value === null) {
         return $this;
     }
     if (is_string($currency) || $currency instanceof Zend_Locale) {
         if (Zend_Locale::isLocale($currency)) {
             $currency = array('locale' => $currency);
         }
     }
     if (is_string($currency)) {
         $currency = array('currency' => $currency);
     }
     if (is_array($currency)) {
         return $this->_currency->toCurrency($value, $currency);
     }
     return $this->_currency->toCurrency($value);
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:25,代码来源:Currency.php

示例14: setAdapter

 /**
  * Sets a new adapter
  *
  * @param string $adapter - adapter to use
  * @param mixed  $options - Adapter options
  * @param mixed  $locale  - OPTIONAL locale to use
  * @return timestamp
  */
 public function setAdapter($adapter, $options, $locale = null)
 {
     if (!($locale = Zend_Locale::isLocale($locale))) {
         throw new Zend_Translate_Exception("language ({$locale}) is a unknown language", $locale);
     }
     switch (strtolower($adapter)) {
         case 'array':
             /** Zend_Translate_Adapter_Array */
             require_once 'Zend/Translate/Adapter/Array.php';
             $this->_adapter = new Zend_Translate_Adapter_Array($options, $locale);
             break;
         case 'cvs':
             throw new Zend_Translate_Exception('not supported for now');
             break;
         case 'gettext':
             /** Zend_Translate_Adapter_Gettext */
             require_once 'Zend/Translate/Adapter/Gettext.php';
             $this->_adapter = new Zend_Translate_Adapter_Gettext($options, $locale);
             break;
         case 'qt':
             throw new Zend_Translate_Exception('not supported for now');
             break;
         case 'sql':
             throw new Zend_Translate_Exception('not supported for now');
             break;
         case 'tbx':
             throw new Zend_Translate_Exception('not supported for now');
             break;
         case 'tmx':
             throw new Zend_Translate_Exception('not supported for now');
             break;
         case 'xliff':
             throw new Zend_Translate_Exception('not supported for now');
             break;
         case 'xmltm':
             throw new Zend_Translate_Exception('not supported for now');
             break;
         default:
             throw new Zend_Translate_Exception('no adapter selected');
             break;
     }
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:50,代码来源:Translate.php

示例15: getLanguages

 /**
  * finds installed languages
  *
  * @static
  * @return array
  */
 public static function getLanguages()
 {
     $languages = array();
     $languageDirs = array(PIMCORE_PATH . "/config/texts/", PIMCORE_CONFIGURATION_DIRECTORY . "/texts/");
     foreach ($languageDirs as $filesDir) {
         if (is_dir($filesDir)) {
             $files = scandir($filesDir);
             foreach ($files as $file) {
                 if (is_file($filesDir . $file)) {
                     $parts = explode(".", $file);
                     if ($parts[1] == "json") {
                         if (\Zend_Locale::isLocale($parts[0])) {
                             $languages[] = $parts[0];
                         }
                     }
                 }
             }
         }
     }
     return $languages;
 }
开发者ID:jansarmir,项目名称:pimcore,代码行数:27,代码来源:Admin.php


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