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


PHP Zend_Translate::getList方法代码示例

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


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

示例1: testGetLanguageList

 public function testGetLanguageList()
 {
     $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('msg1' => 'Message 1'), 'en');
     $lang->addTranslation(array('msg1' => 'Message 1 (ru)'), 'ru');
     $this->assertEquals(count($lang->getList()), 2);
     $this->assertTrue(in_array('en', $lang->getList()));
     $this->assertTrue(in_array('ru', $lang->getList()));
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:8,代码来源:TranslateTest.php

示例2: setLocale

 /** Changes the currently active locale
  * @param string $locale The locale to activate (for example: 'en_US')
  * @param bool $coreOnly = false Set to true to load only the core translation files, set to false (default) to load also packages and site locale translations
  */
 public function setLocale($locale, $coreOnly = false)
 {
     $localeNeededLoading = false;
     if ($locale == 'en_US' && !ENABLE_TRANSLATE_LOCALE_EN_US) {
         if (isset($this->translate)) {
             unset($this->translate);
         }
         return;
     }
     if (is_dir(DIR_LANGUAGES . '/' . $locale)) {
         $languageDir = DIR_LANGUAGES . '/' . $locale;
     } elseif (is_dir(DIR_LANGUAGES_CORE . '/' . $locale)) {
         $languageDir = DIR_LANGUAGES_CORE . '/' . $locale;
     } else {
         return;
     }
     $options = array('adapter' => 'gettext', 'content' => $languageDir, 'locale' => $locale, 'disableNotices' => true, 'ignore' => array('.', 'messages.po'));
     if (defined('TRANSLATE_OPTIONS')) {
         $_options = unserialize(TRANSLATE_OPTIONS);
         if (is_array($_options)) {
             $options = array_merge($options, $_options);
         }
     }
     if (!isset($this->translate)) {
         $this->translate = new Zend_Translate($options);
         $localeNeededLoading = true;
     } else {
         if (!in_array($locale, $this->translate->getList())) {
             $this->translate->addTranslation($options);
             $localeNeededLoading = true;
         }
         $this->translate->setLocale($locale);
     }
     if (!$coreOnly) {
         $this->addSiteInterfaceLanguage($locale);
         global $config_check_failed;
         if (!(isset($config_check_failed) && $config_check_failed)) {
             foreach (PackageList::get(1)->getPackages() as $p) {
                 $pkg = Loader::package($p->getPackageHandle());
                 if (is_object($pkg)) {
                     $pkg->setupPackageLocalization($locale, null, $this->translate);
                 }
             }
         }
     }
     if ($localeNeededLoading) {
         Events::fire('on_locale_load', $locale);
     }
 }
开发者ID:Zyqsempai,项目名称:amanet,代码行数:53,代码来源:localization.php

示例3: testDoubleReroutingForTranslations

 /**
  * @group ZF-2736
  */
 public function testDoubleReroutingForTranslations()
 {
     $translate = new Zend_Translate(array('adapter' => Zend_Translate::AN_ARRAY, 'content' => dirname(__FILE__) . '/Translate/Adapter/_files/testarray/', 'locale' => 'auto', 'scan' => Zend_Translate::LOCALE_FILENAME, 'ignore' => array('.', 'ignoreme', 'LC_TEST'), 'route' => array('ja' => 'en_US', 'en_US' => 'ja')));
     $translate2 = new Zend_Translate(array('adapter' => Zend_Translate::AN_CSV, 'content' => dirname(__FILE__) . '/Translate/Adapter/_files/translation_en.csv', 'locale' => 'en_US'));
     $translate->addTranslation($translate2);
     $langs = $translate->getList();
     $this->assertFalse(array_key_exists('de_DE', $langs));
     $this->assertTrue(array_key_exists('ja', $langs));
     $this->assertTrue(array_key_exists('en_US', $langs));
     $this->assertEquals('Message 5 (en)', $translate->translate('Message 5', 'ja'));
     $this->assertEquals('Message 5 (en)', $translate->translate('Message 5', 'ja'));
 }
开发者ID:sasezaki,项目名称:mirror-zf1-tests,代码行数:15,代码来源:TranslateTest.php

示例4: testFileSearch

 public function testFileSearch()
 {
     $lang = new Zend_Translate(Zend_Translate::AN_CSV, dirname(__FILE__) . '/Translate/_files/test2', null, array('scan' => Zend_Translate::LOCALE_FILENAME));
     $this->assertEquals(2, count($lang->getList()));
     $this->assertTrue(in_array('de_AT', $lang->getList()));
     $this->assertTrue(in_array('de_DE', $lang->getList()));
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:7,代码来源:TranslateTest.php

示例5: array

// global vars
global $errors, $locale, $languages;
// autoloader for zend classes
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance();
$autoloader->registerNamespace('Zend');
// prepare language object
if (isset($_POST['language'])) {
    $currentLang = $_POST['language'];
} else {
    $currentLang = 'en';
}
$locale = new Zend_Translate('csv', 'application/locale', 'en', array('scan' => Zend_Translate::LOCALE_DIRECTORY, 'delimiter' => "|"));
// get languages
$languages = array();
foreach ($locale->getList() as $lang) {
    $languages[$lang] = $locale->translate($lang);
}
// set language
try {
    $languageLocale = new Zend_Locale(Zend_Locale::BROWSER);
    if (in_array($languageLocale->getLanguage(), $locale->getList())) {
        $currentLang = $languageLocale->getLanguage();
        $locale->setLocale($languageLocale);
    }
} catch (Exception $e) {
    $currentLang = 'en';
    $locale->setLocale(new Zend_Locale('en'));
}
// get config
$configDist = new Zend_Config_Ini(CONFIG_DIST_PATH);
开发者ID:google-code-backups,项目名称:rsslounge,代码行数:31,代码来源:install.php

示例6: array

<?php

$options = array('scan' => Zend_Translate::LOCALE_FILENAME);
$translate = new Zend_Translate('array', APPPATH . 'languages/', null, $options);
// $translate->setLocale('en_US');
// $translate->setLocale('nl');
var_dump($translate->getList());
var_dump($translate->getLocale());
echo $translate->_('ADMIN');
开发者ID:jaywilliams,项目名称:ultralite,代码行数:9,代码来源:test-translation.php

示例7: _initSetTranslations

 /**
  * Translations & languages
  */
 protected function _initSetTranslations()
 {
     $session = new Zend_Session_Namespace('Default');
     $available_languages = array();
     // load all php files from languages folder
     foreach (glob(APPLICATION_PATH . '/languages/*.php') as $file) {
         unset($data, $init);
         require_once $file;
         if (!isset($translate)) {
             $translate = new Zend_Translate('array', $data, $init['short']);
         }
         $translate->addTranslation($data, $init['short']);
         $available_languages[$init['short']] = $init['name'];
     }
     if (empty($available_languages)) {
         die('Error: language file is missing ' . APPLICATION_PATH . '/languages/*.php');
     }
     // init Zend_Locale
     $locale = new Zend_Locale();
     // set default language from options
     $default_language = Zend_Registry::get('config')->get('default_language');
     if (!in_array($default_language, $translate->getList())) {
         // in case someone forgot to update settings -> general
         reset($available_languages);
         $default_language = key($available_languages);
     }
     $translate->setLocale($default_language);
     $locale->setLocale($default_language);
     Zend_Registry::set('locale', $default_language);
     // set current language based on user session
     if ($session->language && in_array($session->language, $translate->getList())) {
         $translate->setLocale($session->language);
         $locale->setLocale($session->language);
         Zend_Registry::set('locale', $session->language);
     }
     // push translator to registry
     Zend_Registry::set('Zend_Translate', $translate);
     // push translator to views
     $this->_view->translate = $translate;
     // push translator to forms
     Zend_Form::setDefaultTranslator($translate);
     // sort default as first & save array for forms
     $available_languages_sorted = array();
     if (isset($available_languages[$default_language])) {
         $available_languages_sorted = array($default_language => $available_languages[$default_language]);
         unset($available_languages[$default_language]);
     }
     $available_languages_sorted = array_merge($available_languages_sorted, $available_languages);
     Zend_Registry::set('languages_array', $available_languages_sorted);
 }
开发者ID:georgepaul,项目名称:songslikesocial,代码行数:53,代码来源:Bootstrap.php

示例8: testEmptyTranslation

 /**
  * ZF-7941
  */
 public function testEmptyTranslation()
 {
     $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, null, null, array('disableNotices' => true));
     $this->assertEquals(0, count($lang->getList()));
 }
开发者ID:vicfryzel,项目名称:zf,代码行数:8,代码来源:TranslateTest.php


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