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


PHP Zend_Locale::getDefault方法代码示例

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


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

示例1: testgetDefault

 /**
  * test getDefault
  * expected true
  */
 public function testgetDefault()
 {
     $value = new Zend_Locale();
     $default = $value->getDefault();
     $this->assertTrue(is_array($default), 'No Default Locale found');
     $default = $value->getDefault(Zend_Locale::BROWSER);
     $this->assertTrue(is_array($default), 'No Default Locale found');
     $default = $value->getDefault(Zend_Locale::ENVIRONMENT);
     $this->assertTrue(is_array($default), 'No Default Locale found');
     $default = $value->getDefault(Zend_Locale::FRAMEWORK);
     $this->assertTrue(is_array($default), 'No Default Locale found');
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:16,代码来源:LocaleTest.php

示例2: __construct

 public function __construct($locale = null)
 {
     if ($locale === null) {
         $locale = key(Zend_Locale::getDefault());
     } elseif (empty($locale)) {
         $locale = 'en_US';
     }
     $this->locale = $locale;
 }
开发者ID:grlf,项目名称:eyedock,代码行数:9,代码来源:Locale.php

示例3: localeShort

 public function localeShort()
 {
     $translator = $this->view->getHelper('translate')->getTranslator();
     $locale = $translator->getLocale();
     if (!$translator->isAvailable($locale)) {
         $defaults = Zend_Locale::getDefault();
         arsort($defaults);
         $locale = key($defaults);
     }
     $locale = new Zend_Locale($locale);
     return $locale->getLanguage();
 }
开发者ID:niavok,项目名称:syj,代码行数:12,代码来源:LocaleShort.php

示例4: getRouter

 /**
  * Retrieve router object
  *
  * @return Zend_Controller_Router_Rewrite
  */
 public function getRouter()
 {
     $routesIni = $this->_getRoutesConfig();
     $this->setOptions($routesIni->toArray());
     $options = $this->getOptions();
     if ($this->_localeIsEnabled()) {
         $bootstrap = $this->getBootstrap();
         if (!$this->_locale) {
             $bootstrap->bootstrap('Locale');
             $this->_locale = $bootstrap->getContainer()->locale;
         }
         $defaultLocale = array_keys($this->_locale->getDefault());
         $defaultLocale = $defaultLocale[0];
         $locales = $this->_getPossibleLocales();
         $routes = $options['routes'];
         $localizedRoutes = Garp_I18n::getLocalizedRoutes($routes, $locales);
         $options['routes'] = array_merge($routes, $localizedRoutes);
         $this->setOptions($options);
     }
     $router = parent::getRouter();
     $router->addDefaultRoutes();
     return $router;
 }
开发者ID:grrr-amsterdam,项目名称:garp3,代码行数:28,代码来源:Router.php

示例5: Translate

 public function Translate($text)
 {
     $translated = $text;
     try {
         $locale = new Zend_Locale(Zend_Locale::BROWSER);
         $translate = Zend_Registry::get('translate');
         if (!$translate->isAvailable($locale)) {
             $translate->setLocale(Zend_Locale::getDefault());
         }
         $translated = $translate->_($text);
     } catch (Exception $e) {
         Zend_Registry::get('logger')->err($e->getMessage());
     }
     return $translated;
 }
开发者ID:akeemphilbert,项目名称:ifphp,代码行数:15,代码来源:Translate.php

示例6: getTranslate

 /**
  * Retrieve translate object
  *
  * @return Zend_Translate
  */
 public function getTranslate()
 {
     $options = $this->getOptions();
     if (!isset($options['data'])) {
         throw new Zend_Application_Resource_Exception('No translation source data provided in the ini file for: ' . get_class($this->getBootstrap()) . '.');
     }
     foreach (Zend_Locale::getDefault() as $default => $value) {
         break;
     }
     $adapter = isset($options['adapter']) ? $options['adapter'] : Zend_Translate::AN_ARRAY;
     $locale = isset($options['locale']) ? $options['locale'] : $default;
     $translateOptions = isset($options['options']) ? $options['options'] : array();
     $key = isset($options['registry_key']) && !is_numeric($options['registry_key']) ? $options['registry_key'] : self::DEFAULT_REGISTRY_KEY;
     // If no translate object was set in the registry we create it.
     if (!Zend_Registry::isRegistered($key)) {
         $this->_createTranslation($adapter, $options['data'], $locale, $translateOptions);
         // if there is, we should add a translation source to the existing translate object
     } elseif (Zend_Registry::isRegistered($key)) {
         $this->_translate = Zend_Registry::get($key);
         $this->_addTranslation($options['data'], $locale, $translateOptions);
     }
     Zend_Registry::set($key, $this->_translate);
     return $this->_translate;
 }
开发者ID:visualweber,项目名称:appzf1,代码行数:29,代码来源:Translate.php

示例7: testgetDefault

 /**
  * test getDefault
  * expected true
  */
 public function testgetDefault()
 {
     Zend_Locale::setDefault('de');
     $value = new Zend_Locale();
     $default = $value->getDefault();
     $this->assertTrue(array_key_exists('de', $default));
     $default = $value->getDefault();
     $this->assertTrue(is_array($default));
     $default = $value->getDefault(Zend_Locale::BROWSER);
     $this->assertTrue(is_array($default));
     $default = $value->getDefault(Zend_Locale::ENVIRONMENT);
     $this->assertTrue(is_array($default));
     $default = $value->getDefault(Zend_Locale::FRAMEWORK);
     $this->assertTrue(is_array($default));
 }
开发者ID:jon9872,项目名称:zend-framework,代码行数:19,代码来源:LocaleTest.php

示例8: isLocale

    /**
     * Checks if a locale identifier is a real locale or not
     * Examples:
     * "en_XX" refers to "en", which returns true
     * "XX_yy" refers to "root", which returns false
     *
     * @param  string|Zend_Locale  $locale  Locale to check for
     * @param  boolean             $create  If true, create a default locale, if $locale is empty
     * @return false|string   false if given locale is not a locale, else the locale identifier is returned
     */
    public static function isLocale($locale, $create = false)
    {
        if (empty($locale) and ($create === true)) {
            $locale = new Zend_Locale();
        }
        if ($locale instanceof Zend_Locale) {
            return $locale->toString();
        }
        if (!is_string($locale)) {
            return false;
        }
        if (empty(self::$_auto)) {
            $temp = new Zend_Locale($locale);
            self::$_auto        = $temp->getDefault(null, false);
            self::$_browser     = $temp->getDefault(self::BROWSER, false);
            self::$_environment = $temp->getDefault(self::ENVIRONMENT, false);
        }
        if ($locale == 'auto') {
            $locale = self::$_auto;
        }
        if ($locale == 'browser') {
            $locale = self::$_browser;
        }
        if ($locale == 'environment') {
            $locale = self::$_environment;
        }
        if (is_array($locale)) {
            $locale = key($locale);
        }

        if (array_key_exists($locale, self::$_localeData)) {
            return $locale;
        } else {
            $locale = explode('_', $locale);
            if (array_key_exists($locale[0], self::$_localeData)) {
                return $locale[0];
            }
        }
        return false;
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:50,代码来源:Locale.php

示例9: getDefaultLocale

 function getDefaultLocale($addRegion = false)
 {
     @(list($found, ) = array_keys(Zend_Locale::getDefault()));
     if (!$found) {
         return 'en_US';
     }
     if (!$addRegion) {
         return $found;
     }
     return strlen($found) <= 4 ? ___('_default_locale') : $found;
 }
开发者ID:alexanderTsig,项目名称:arabic,代码行数:11,代码来源:App.php

示例10: getLanguage

 public function getLanguage()
 {
     return Zend_Locale::getDefault();
 }
开发者ID:netconstructor,项目名称:Centurion,代码行数:4,代码来源:Item.php

示例11: testDefaultFramework

 /**
  * test getDefaultFramework
  * expected true
  */
 public function testDefaultFramework()
 {
     $value = new Zend_Locale();
     $default = $value->getDefault(Zend_Locale::FRAMEWORK);
     $this->assertTrue(is_array($default), 'No Default Locale found');
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:10,代码来源:LocaleTest.php

示例12: getLanguage

 public function getLanguage()
 {
     $_list = $this->getLangaugeList();
     $_locale = key(Zend_Locale::getDefault());
     if (!array_key_exists($_locale, $_list)) {
         list($_locale) = explode('_', $_locale);
     }
     return $_locale;
 }
开发者ID:grlf,项目名称:eyedock,代码行数:9,代码来源:Brick.php

示例13: _getLocaleDate

 /**
  * Return Zend_Date object with browser sent|german locale.
  *
  * @param Zend_Date $timestamp
  * @return Zend_Locale
  */
 protected function _getLocaleDate(Zend_Date $date)
 {
     // TODO Get currently used locale in a better/easier way.
     if (!self::$_locale) {
         $currentLocales = Zend_Locale::getDefault();
         self::$_locale = key($currentLocales);
     }
     $date = $date->setLocale(self::$_locale);
     return $date;
 }
开发者ID:JaXt0r,项目名称:EewAzVvE,代码行数:16,代码来源:Date.php

示例14: get_locale

function get_locale()
{
    $locale = new Zend_Locale();
    return $locale->getDefault();
}
开发者ID:basdog22,项目名称:Qool,代码行数:5,代码来源:layer.php


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