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


PHP Zend_Locale::getEnvironment方法代码示例

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


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

示例1: _addTranslationData

 protected function _addTranslationData($data, $locale, array $options = array())
 {
     try {
         $locale = Zend_Locale::findLocale($locale);
     } catch (Zend_Locale_Exception $e) {
         require_once 'Zend/Translate/Exception.php';
         throw new Zend_Translate_Exception("The given Language '{$locale}' does not exist");
     }
     if ($options['clear'] || !isset($this->_translate[$locale])) {
         $this->_translate[$locale] = array();
     }
     $ext = strtolower(ltrim(strrchr($data, '.'), '.'));
     if (!isset($this->_extToParser[$ext])) {
         return false;
     }
     $class = $this->_extToParser[$ext];
     $temp = call_user_func(array($class, 'parse'), $data, $locale, $options);
     if (empty($temp)) {
         $temp = array();
     }
     $keys = array_keys($temp);
     foreach ($keys as $key) {
         if (!isset($this->_translate[$key])) {
             $this->_translate[$key] = array();
         }
         $this->_translate[$key] = $temp[$key] + $this->_translate[$key];
     }
     if ($this->_automatic === true) {
         $find = new Zend_Locale($locale);
         $browser = $find->getEnvironment() + $find->getBrowser();
         arsort($browser);
         foreach ($browser as $language => $quality) {
             if (isset($this->_translate[$language])) {
                 $this->_options['locale'] = $language;
                 break;
             }
         }
     }
     return $this;
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:40,代码来源:Null.php

示例2: _addTranslationData

 /**
  * Internal function for adding translation data
  *
  * It may be a new language or additional data for existing language
  * If $clear parameter is true, then translation data for specified
  * language is replaced and added otherwise
  *
  * @see    Zend_Locale
  * @param  array|string       $data    Translation data
  * @param  string|Zend_Locale $locale  Locale/Language to add data for, identical with locale identifier,
  *                                     @see Zend_Locale for more information
  * @param  array              $options (optional) Option for this Adapter
  * @throws Zend_Translate_Exception
  * @return Zend_Translate_Adapter Provides fluent interface
  */
 private function _addTranslationData($data, $locale, array $options = array())
 {
     try {
         $locale = Zend_Locale::findLocale($locale);
     } catch (Zend_Locale_Exception $e) {
         require_once 'Zend/Translate/Exception.php';
         throw new Zend_Translate_Exception("The given Language '{$locale}' does not exist", 0, $e);
     }
     if ($options['clear'] || !isset($this->_translate[$locale])) {
         $this->_translate[$locale] = array();
     }
     $read = true;
     if (isset(self::$_cache)) {
         $id = 'Zend_Translate_' . md5(serialize($data)) . '_' . $this->toString();
         $temp = self::$_cache->load($id);
         if ($temp) {
             $read = false;
         }
     }
     if ($options['reload']) {
         $read = true;
     }
     if ($read) {
         $temp = $this->_loadTranslationData($data, $locale, $options);
     }
     if (empty($temp)) {
         $temp = array();
     }
     $keys = array_keys($temp);
     foreach ($keys as $key) {
         if (!isset($this->_translate[$key])) {
             $this->_translate[$key] = array();
         }
         if (array_key_exists($key, $temp) && is_array($temp[$key])) {
             $this->_translate[$key] = $temp[$key] + $this->_translate[$key];
         }
     }
     if ($this->_automatic === true) {
         $find = new Zend_Locale($locale);
         $browser = $find->getEnvironment() + $find->getBrowser();
         arsort($browser);
         foreach ($browser as $language => $quality) {
             if (isset($this->_translate[$language])) {
                 $this->_options['locale'] = $language;
                 break;
             }
         }
     }
     if ($read and isset(self::$_cache)) {
         $id = 'Zend_Translate_' . md5(serialize($data)) . '_' . $this->toString();
         self::$_cache->save($temp, $id, array('Zend_Translate'));
     }
     return $this;
 }
开发者ID:kdambekalns,项目名称:framework-benchs,代码行数:69,代码来源:Adapter.php

示例3: _addTranslationData

 /**
  * Internal function for adding translation data
  *
  * It may be a new language or additional data for existing language
  * If $clear parameter is true, then translation data for specified
  * language is replaced and added otherwise
  *
  * @see    Zend_Locale
  * @param  array|string       $data    Translation data
  * @param  string|Zend_Locale $locale  Locale/Language to add data for, identical with locale identifier,
  *                                     @see Zend_Locale for more information
  * @param  array              $options (optional) Option for this Adapter
  * @throws Zend_Translate_Exception
  * @return Zend_Translate_Adapter Provides fluent interface
  */
 private function _addTranslationData($data, $locale, array $options = array())
 {
     if (!Zend_Locale::isLocale($locale, true, false)) {
         if (!Zend_Locale::isLocale($locale, false, false)) {
             /**
              * @see Zend_Translate_Exception
              */
             require_once 'Zend/Translate/Exception.php';
             throw new Zend_Translate_Exception("The given Language ({$locale}) does not exist");
         }
         $locale = new Zend_Locale($locale);
     }
     $locale = (string) $locale;
     if (isset($this->_translate[$locale]) === false) {
         $this->_translate[$locale] = array();
     }
     $read = true;
     if (isset(self::$_cache)) {
         $id = 'Zend_Translate_' . preg_replace('/[^a-zA-Z0-9_]/', '_', $data) . '_' . $locale . '_' . $this->toString();
         $result = self::$_cache->load($id);
         if ($result) {
             $this->_translate[$locale] = unserialize($result);
             $read = false;
         }
     }
     if ($read) {
         $this->_loadTranslationData($data, $locale, $options);
     }
     if ($this->_automatic === true) {
         $find = new Zend_Locale($locale);
         $browser = $find->getEnvironment() + $find->getBrowser();
         arsort($browser);
         foreach ($browser as $language => $quality) {
             if (isset($this->_translate[$language]) === true) {
                 $this->_options['locale'] = $language;
                 break;
             }
         }
     }
     if ($read and isset(self::$_cache)) {
         $id = 'Zend_Translate_' . preg_replace('/[^a-zA-Z0-9_]/', '_', $data) . '_' . $locale . '_' . $this->toString();
         self::$_cache->save(serialize($this->_translate[$locale]), $id);
     }
     return $this;
 }
开发者ID:ankuradhey,项目名称:dealtrip,代码行数:60,代码来源:Adapter.php

示例4: testEnvironment

 /**
  * test getEnvironment
  * expected true
  */
 public function testEnvironment()
 {
     $value = new Zend_Locale();
     $default = $value->getEnvironment();
     $this->assertTrue(is_array($default));
 }
开发者ID:jon9872,项目名称:zend-framework,代码行数:10,代码来源:LocaleTest.php

示例5: _addTranslationData

 /**
  * Internal function for adding translation data
  *
  * This may be a new language or additional data for an existing language
  * If the options 'clear' is true, then the translation data for the specified
  * language is replaced and added otherwise
  *
  * @see    Zend_Locale
  * @param  array|Zend_Config $content Translation data to add
  * @throws Zend_Translate_Exception
  * @return Zend_Translate_Adapter Provides fluent interface
  */
 private function _addTranslationData($options = array())
 {
     if ($options instanceof Zend_Config) {
         $options = $options->toArray();
     } else {
         if (func_num_args() > 1) {
             $args = func_get_args();
             $options['content'] = array_shift($args);
             if (!empty($args)) {
                 $options['locale'] = array_shift($args);
             }
             if (!empty($args)) {
                 $options += array_shift($args);
             }
         }
     }
     if ($options['content'] instanceof Zend_Translate || $options['content'] instanceof Zend_Translate_Adapter) {
         $options['usetranslateadapter'] = true;
         if (!empty($options['locale']) && $options['locale'] !== 'auto') {
             $options['content'] = $options['content']->getMessages($options['locale']);
         } else {
             $content = $options['content'];
             $locales = $content->getList();
             foreach ($locales as $locale) {
                 $options['locale'] = $locale;
                 $options['content'] = $content->getMessages($locale);
                 $this->_addTranslationData($options);
             }
             return $this;
         }
     }
     try {
         $options['locale'] = Zend_Locale::findLocale($options['locale']);
     } catch (Zend_Locale_Exception $e) {
         #require_once 'Zend/Translate/Exception.php';
         throw new Zend_Translate_Exception("The given Language '{$options['locale']}' does not exist", 0, $e);
     }
     if ($options['clear'] || !isset($this->_translate[$options['locale']])) {
         $this->_translate[$options['locale']] = array();
     }
     $read = true;
     if (isset(self::$_cache)) {
         $id = 'Zend_Translate_' . md5(serialize($options['content'])) . '_' . $this->toString();
         $temp = self::$_cache->load($id);
         if ($temp) {
             $read = false;
         }
     }
     if ($options['reload']) {
         $read = true;
     }
     if ($read) {
         if (!empty($options['usetranslateadapter'])) {
             $temp = array($options['locale'] => $options['content']);
         } else {
             $temp = $this->_loadTranslationData($options['content'], $options['locale'], $options);
         }
     }
     if (empty($temp)) {
         $temp = array();
     }
     $keys = array_keys($temp);
     foreach ($keys as $key) {
         if (!isset($this->_translate[$key])) {
             $this->_translate[$key] = array();
         }
         if (array_key_exists($key, $temp) && is_array($temp[$key])) {
             $this->_translate[$key] = $temp[$key] + $this->_translate[$key];
         }
     }
     if ($this->_automatic === true) {
         $find = new Zend_Locale($options['locale']);
         $browser = $find->getEnvironment() + $find->getBrowser();
         arsort($browser);
         foreach ($browser as $language => $quality) {
             if (isset($this->_translate[$language])) {
                 $this->_options['locale'] = $language;
                 break;
             }
         }
     }
     if ($read and isset(self::$_cache)) {
         $id = 'Zend_Translate_' . md5(serialize($options['content'])) . '_' . $this->toString();
         if (self::$_cacheTags) {
             self::$_cache->save($temp, $id, array($this->_options['tag']));
         } else {
             self::$_cache->save($temp, $id);
         }
//.........这里部分代码省略.........
开发者ID:ankitsapient,项目名称:testgithubankit,代码行数:101,代码来源:Adapter.php

示例6: _addTranslationData

 /**
  * Internal function for adding translation data
  *
  * It may be a new language or additional data for existing language
  * If $clear parameter is true, then translation data for specified
  * language is replaced and added otherwise
  *
  * @see    Zend_Locale
  * @param  array|string       $data    Translation data
  * @param  string|Zend_Locale $locale  Locale/Language to add data for, identical with locale identifier,
  *                                     @see Zend_Locale for more information
  * @param  array              $options (optional) Option for this Adapter
  * @throws Zend_Translate_Exception
  * @return Zend_Translate_Adapter Provides a fluid interface
  */
 private function _addTranslationData($data, $locale, array $options = array())
 {
     if (!($locale = Zend_Locale::isLocale($locale))) {
         /**
          * @see Zend_Translate_Exception
          */
         require_once 'Zend/Translate/Exception.php';
         throw new Zend_Translate_Exception("The given Language ({$locale}) does not exist");
     }
     if (!array_key_exists($locale, $this->_translate)) {
         $this->_translate[$locale] = array();
     }
     $this->_loadTranslationData($data, $locale, $options);
     if ($this->_automatic === true) {
         $find = new Zend_Locale($locale);
         $browser = $find->getBrowser() + $find->getEnvironment();
         arsort($browser);
         foreach ($browser as $language => $quality) {
             if (array_key_exists($language, $this->_translate)) {
                 $this->_options['locale'] = $language;
                 break;
             }
         }
     }
     if (isset(self::$_cache)) {
         $id = 'Zend_Translate_' . $this->toString();
         $temp = $this->_translate;
         $temp['_options_'] = $this->_options;
         self::$_cache->save(serialize($temp), $id);
     }
     return $this;
 }
开发者ID:Spark-Eleven,项目名称:revive-adserver,代码行数:47,代码来源:Adapter.php

示例7: addTranslation

    /**
     * Add translation data
     *
     * It may be a new language or additional data for existing language
     * If $clear parameter is true, then translation data for specified
     * language is replaced and added otherwise
     *
     * @param  array|string          $data    Translation data
     * @param  string|Zend_Locale    $locale  Locale/Language to add data for, identical with locale identifier,
     *                                        see Zend_Locale for more information
     * @param  array                 $options OPTIONAL Option for this Adapter
     * @throws Zend_Translate_Exception
     */
    public function addTranslation($data, $locale, array $options = array())
    {
        if (!$locale = Zend_Locale::isLocale($locale)) {
            throw new Zend_Translate_Exception("The given Language ({$locale}) does not exist");
        }

        if (!in_array($locale, $this->_languages)) {
            $this->_languages[$locale] = $locale;
        }

        $this->_loadTranslationData($data, $locale, $options);
        if ($this->_automatic === true) {
            $find = new Zend_Locale($locale);
            $browser = $find->getBrowser() + $find->getEnvironment();
            arsort($browser);
            foreach($browser as $language => $quality) {
                if (in_array($language, $this->_languages)) {
                    $this->_locale = $language;
                    break;
                }
            }
        }
    }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:36,代码来源:Adapter.php

示例8: testIsLocale

 /**
  * test isLocale
  * expected boolean
  */
 public function testIsLocale()
 {
     $locale = new Zend_LocaleTestHelper('ar');
     $this->assertTrue(Zend_LocaleTestHelper::isLocale($locale));
     $this->assertTrue(Zend_LocaleTestHelper::isLocale('de'));
     $this->assertTrue(Zend_LocaleTestHelper::isLocale('de_AT'));
     $this->assertTrue(Zend_LocaleTestHelper::isLocale('de_xx'));
     $this->assertFalse(Zend_LocaleTestHelper::isLocale('yy'));
     $this->assertFalse(Zend_LocaleTestHelper::isLocale(1234));
     $this->assertFalse(Zend_LocaleTestHelper::isLocale('', true));
     $this->assertFalse(Zend_LocaleTestHelper::isLocale('', false));
     $this->assertTrue(Zend_LocaleTestHelper::isLocale('auto'));
     $this->assertTrue(Zend_LocaleTestHelper::isLocale('browser'));
     if (count(Zend_Locale::getEnvironment()) != 0) {
         $this->assertTrue(Zend_LocaleTestHelper::isLocale('environment'));
     }
     set_error_handler(array($this, 'errorHandlerIgnore'));
     Zend_LocaleTestHelper::$compatibilityMode = true;
     $this->assertEquals('ar', Zend_LocaleTestHelper::isLocale($locale));
     $this->assertEquals('de', Zend_LocaleTestHelper::isLocale('de'));
     $this->assertEquals('de_AT', Zend_LocaleTestHelper::isLocale('de_AT'));
     $this->assertEquals('de', Zend_LocaleTestHelper::isLocale('de_xx'));
     $this->assertFalse(Zend_LocaleTestHelper::isLocale('yy'));
     $this->assertFalse(Zend_LocaleTestHelper::isLocale(1234));
     $this->assertFalse(Zend_LocaleTestHelper::isLocale('', true));
     $this->assertFalse(Zend_LocaleTestHelper::isLocale('', false));
     $this->assertTrue(is_string(Zend_LocaleTestHelper::isLocale('auto')));
     $this->assertTrue(is_string(Zend_LocaleTestHelper::isLocale('browser')));
     if (count(Zend_Locale::getEnvironment()) != 0) {
         $this->assertTrue(is_string(Zend_LocaleTestHelper::isLocale('environment')));
     }
     restore_error_handler();
 }
开发者ID:netvlies,项目名称:zf,代码行数:37,代码来源:LocaleTest.php

示例9: addTranslation

 /**
  * Add translation data
  *
  * It may be a new language or additional data for existing language
  * If $clear parameter is true, then translation data for specified
  * language is replaced and added otherwise
  *
  * @param  array|string          $data    Translation data
  * @param  string|Zend_Locale    $locale  Locale/Language to add data for, identical with locale identifier,
  *                                        see Zend_Locale for more information
  * @param  array                 $options OPTIONAL Option for this Adapter
  * @throws Zend_Translate_Exception
  */
 public function addTranslation($data, $locale, array $options = array())
 {
     if (!($locale = Zend_Locale::isLocale($locale))) {
         throw new Zend_Translate_Exception("The given Language ({$locale}) does not exist");
     }
     if (!array_key_exists($locale, $this->_translate)) {
         $this->_translate[$locale] = array();
     }
     $this->_loadTranslationData($data, $locale, $options);
     if ($this->_automatic === true) {
         $find = new Zend_Locale($locale);
         $browser = $find->getBrowser() + $find->getEnvironment();
         arsort($browser);
         foreach ($browser as $language => $quality) {
             if (array_key_exists($language, $this->_translate)) {
                 $this->_locale = $language;
                 break;
             }
         }
     }
     if (isset(self::$_cache)) {
         $id = 'Zend_Translate_' . $this->toString();
         self::$_cache->save(serialize($this->_translate), $id);
     }
 }
开发者ID:ismaelmelus,项目名称:home,代码行数:38,代码来源:Adapter.php

示例10: setlocale

<?php

require_once "Zend/Locale.php";
echo "Setting locale to: " . setlocale(LC_ALL, 'C') . "\n";
echo "Setting default to de_DE\n";
Zend_Locale::setDefault('de_DE');
echo "Environment: ";
var_dump(Zend_Locale::getEnvironment());
$locale = new Zend_Locale('auto');
echo "This should be de_DE: {$locale}\n";
开发者ID:Tony133,项目名称:zf-web,代码行数:10,代码来源:test.php


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