本文整理汇总了PHP中Zend_Translate::getLocale方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Translate::getLocale方法的具体用法?PHP Zend_Translate::getLocale怎么用?PHP Zend_Translate::getLocale使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Translate
的用法示例。
在下文中一共展示了Zend_Translate::getLocale方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getValues
public static function getValues(Zend_Translate $lang)
{
$countries = Zend_Locale::getTranslationList('Territory', $lang->getLocale(), 2);
$continents = Zend_Locale::getTranslationList('Territory', $lang->getLocale(), 1);
array_unshift($countries, current($continents));
return $countries;
}
示例2: testSetLocale
public function testSetLocale()
{
$lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('msg1' => 'Message 1'), 'en');
$lang->addTranslation('ru', array('msg1' => 'Message 1 (ru)'));
$this->assertEquals($lang->getLocale(), new Zend_Locale('en'));
$lang->setLocale('ru');
$this->assertEquals($lang->getLocale(), new Zend_Locale('ru'));
}
示例3: addSiteInterfaceLanguage
/** Loads the site interface locale.
* @param string $locale = null The locale to load (for instance: 'en_US'). If empty we'll use the currently active locale
*/
public function addSiteInterfaceLanguage($locale = null)
{
if (is_object($this->translate)) {
if (!(is_string($locale) && strlen($locale))) {
$locale = $this->translate->getLocale();
}
$path = DIR_LANGUAGES_SITE_INTERFACE . '/' . $locale . '.mo';
if (is_file($path)) {
$this->translate->addTranslation($path, $locale);
}
}
}
示例4: testSetLocaleAsOption
/**
* Tests if setting locale as options sets locale
*/
public function testSetLocaleAsOption()
{
$lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array('msg1' => 'Message 1'), 'en');
$lang->addTranslation(array('msg1' => 'Message 1 (ru)'), 'ru');
$lang->setOptions(array('locale' => 'ru'));
$this->assertEquals('ru', $lang->getLocale());
$lang->setOptions(array('locale' => 'en'));
$this->assertEquals('en', $lang->getLocale());
}
示例5: _initDb
/**
* Init the db
*/
protected function _initDb()
{
if (!Zend_Registry::isRegistered('db')) {
# $config = new Zend_Config_Ini( APPLICATION_PATH . '/config.ini', APPLICATION_ENV );
$config = new Zend_Config_Ini(APPLICATION_PATH . '/config.ini', ENVIRONMENT);
$db = Zend_Db::factory($config->resources->db);
Zend_Db_Table_Abstract::setDefaultAdapter($db);
Zend_Registry::set('db', $db);
}
// setup language
if (!Zend_Registry::isRegistered('translate')) {
$translate = new Zend_Translate('csv', SERVER_BASE . LANGUAGES . 'en.csv', 'en');
$actual = $translate->getLocale();
// $language = get_session( 'language' );
$language = Zend_Registry::isRegistered('language') ? Zend_Registry::get('language') : '';
if ($language == '' or $language == '*') {
$language = substr(get_ip(), 0, 3) == '58.' ? 'zh-Hans' : LANGUAGE;
// set_session( 'language', $language );
Zend_Registry::set('language', $language);
}
$translate->addTranslation(SERVER_BASE . LANGUAGES . $language . '.csv', substr($language, 0, 2));
$locale = new Zend_Locale('en_US');
Zend_Registry::set('translate', $translate);
}
}
示例6:
function __($msg)
{
if (!Zend_Registry::isRegistered('translate')) {
$translate = new Zend_Translate('array', __DIR__ . '/Zyon.lang.php', 'auto');
if (is_file($file = APPLICATION_PATH . '/languages/' . $translate->getLocale() . '.php')) {
$translate->addTranslation($file);
}
Zend_Registry::set('translate', $translate);
}
$msg = (string) $msg;
$ret = (string) Zend_Registry::get('translate')->getAdapter()->translate($msg, null);
if (func_num_args() > 1) {
$args = func_get_args();
$args[0] = $ret;
return call_user_func_array('sprintf', $args);
}
return $ret;
}
示例7: 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');
示例8: _initTranslate
protected function _initTranslate()
{
$translate = new Zend_Translate(array('adapter' => 'array', 'content' => ROOT_PATH . '/languages/admin_nl.php', 'locale' => 'nl'));
$session = new Zend_Session_Namespace('Lang');
if (isset($session->language)) {
$translate->setLocale($session->language);
} else {
$session->language = $translate->getLocale();
}
Zend_Registry::set('Zend_Translate', $translate);
return $translate;
}
示例9: getValues
public static function getValues(Zend_Translate $lang)
{
return Zend_Locale::getTranslationList('Territory', $lang->getLocale(), 1);
}