本文整理汇总了PHP中Zend_Locale::getTranslationList方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Locale::getTranslationList方法的具体用法?PHP Zend_Locale::getTranslationList怎么用?PHP Zend_Locale::getTranslationList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Locale
的用法示例。
在下文中一共展示了Zend_Locale::getTranslationList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _getCountries
/**
* Get a localized list of countries sorted by country name
*
* @return array
*/
private function _getCountries()
{
$countries = Zend_Locale::getTranslationList('territory', null, 2);
asort($countries, SORT_LOCALE_STRING);
array_unshift($countries, '---');
return $countries;
}
示例2: init
public function init()
{
$this->setTitle('Language Manager')->setDescription('Create a new language pack')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));
$localeObject = Zend_Registry::get('Locale');
$languages = Zend_Locale::getTranslationList('language', $localeObject);
$territories = Zend_Locale::getTranslationList('territory', $localeObject);
$localeMultiOptions = array();
foreach (array_keys(Zend_Locale::getLocaleList()) as $key) {
$languageName = null;
if (!empty($languages[$key])) {
$languageName = $languages[$key];
} else {
$tmpLocale = new Zend_Locale($key);
$region = $tmpLocale->getRegion();
$language = $tmpLocale->getLanguage();
if (!empty($languages[$language]) && !empty($territories[$region])) {
$languageName = $languages[$language] . ' (' . $territories[$region] . ')';
}
}
if ($languageName) {
$localeMultiOptions[$key] = $languageName . ' [' . $key . ']';
}
}
//asort($languageNameList);
$this->addElement('Select', 'language', array('label' => 'Language', 'description' => 'Which language do you want to create a language pack for?', 'multiOptions' => $localeMultiOptions));
// Init submit
$this->addElement('Button', 'submit', array('label' => 'Create', 'type' => 'submit', 'decorators' => array('ViewHelper')));
$this->addElement('Cancel', 'cancel', array('prependText' => ' or ', 'link' => true, 'label' => 'cancel', 'onclick' => 'history.go(-1); return false;', 'decorators' => array('ViewHelper')));
}
示例3: 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;
}
示例4: getMonths
protected function getMonths()
{
if (!isset($this->_month)) {
$this->_month = Zend_Locale::getTranslationList('month');
}
return $this->_month;
}
示例5: getFromList
public function getFromList(&$list)
{
$current_locale = I18n::getInstance()->getCurrentLanguage();
$country = BizSystem::clientProxy()->getFormInputs("fld_region");
$country = strtoupper($country);
if (!$country) {
$locale = explode('_', $current_locale);
$country = strtoupper($locale[0]);
}
require_once 'Zend/Locale.php';
$locale = new Zend_Locale($current_locale);
$code2name = $locale->getTranslationList('territorytolanguage', $locale);
$list = array();
$i = 0;
foreach ($code2name as $key => $value) {
if (preg_match('/' . $country . '/', $value) || strtoupper($key) == $country) {
$lang_list = explode(" ", $value);
foreach ($lang_list as $lang) {
$list[$i]['txt'] = strtolower($key) . "_" . strtoupper($lang);
$list[$i]['val'] = strtolower($key) . "_" . strtoupper($lang);
$i++;
}
}
}
return $list;
}
示例6: toOptionArray
public function toOptionArray()
{
// scan the TinyMCE langs directory for javascript files and present
// thse as languages options
$langs = array();
$langsDir = Mage::getBaseDir() . '/js/fontis/tiny_mce/langs/';
if (is_dir($langsDir)) {
$locale = Mage::getStoreConfig('general/locale/code');
if (!$locale) {
$locale = 'en';
}
$translationList = Zend_Locale::getTranslationList('language', $locale);
$contents = scandir($langsDir);
foreach ($contents as $item) {
if ($item != "." && $item != ".." && is_file($langsDir . $item) && substr($item, -3) == ".js") {
$code = substr($item, 0, -3);
if (array_key_exists($code, $translationList)) {
$label = $translationList[$code];
} else {
$label = $code;
}
$langEntry = array('value' => $code, 'label' => $label);
$langs[] = $langEntry;
}
}
}
if (!empty($langs)) {
return $langs;
} else {
return array(array('value' => 'en', 'label' => 'en'));
}
}
示例7: init
public function init()
{
$this->setMethod('post');
$this->addElement('text', 'fullname', array('label' => 'Name', 'required' => false, 'filters' => array('StringTrim', 'StripTags'), 'class' => 'title'));
$this->addElement('text', 'nickname', array('label' => 'Nickname', 'required' => false, 'filters' => array('StringTrim', 'StripTags'), 'class' => 'text'));
$this->addElement('text', 'email', array('label' => 'Email', 'required' => false, 'validators' => array('emailAddress'), 'filters' => array('StringTrim', 'StripTags'), 'class' => 'text'));
$this->addElement('select', 'gender', array('label' => 'Gender', 'required' => false, 'validators' => array(array('inArray', false, array(array('M', 'F')))), 'multiOptions' => array('' => 'Not specified', 'M' => 'Male', 'F' => 'Female')));
$this->addElement('text', 'dob', array('label' => 'Date of birth (dd/mm/yyyy)', 'required' => false, 'class' => 'text', 'validators' => array(array('date', false, array('d/m/Y'))), 'filters' => array('StringTrim', 'StripTags')));
// get the list of countries
$countries = Zend_Locale::getTranslationList('Territory', 'en', 2);
asort($countries, SORT_LOCALE_STRING);
$country = new Zend_Form_Element_Select('country');
$country->setLabel('Country')->addMultiOption('', 'Not specified')->addMultiOption('GB', 'United Kingdom')->addMultiOptions($countries)->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim');
$postcode = new Zend_Form_Element_Text('postcode');
$postcode->setLabel('Postcode')->setAttrib("class", "text")->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
$languages = Zend_Locale::getTranslationList('Language', 'en');
asort($languages, SORT_LOCALE_STRING);
$language = new Zend_Form_Element_Select('language');
$language->setLabel('Language')->addMultiOption('', 'Not specified')->addMultiOption('en_GB', 'British English')->addMultiOptions($languages)->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim');
$timeZone = new Zend_Form_Element_Text('timezone');
$timeZone->setLabel('Timezone')->setAttrib("class", "text")->setRequired(false)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
$this->addElements(array($country, $postcode, $language, $timeZone));
$this->addElement('submit', 'submit', array('ignore' => true, 'label' => 'Save'));
$this->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'fieldset')), array('Description', array('placement' => 'prepend', 'class' => 'error')), 'Form'));
}
示例8: init
public function init()
{
$this->setTitle('Locale Settings')->setDescription('CORE_FORM_ADMIN_SETTINGS_LOCALE_DESCRIPTION');
// Init timezeon
$this->addElement('Select', 'timezone', array('label' => 'Default Timezone', 'multiOptions' => array('US/Pacific' => '(UTC-8) Pacific Time (US & Canada)', 'US/Mountain' => '(UTC-7) Mountain Time (US & Canada)', 'US/Central' => '(UTC-6) Central Time (US & Canada)', 'US/Eastern' => '(UTC-5) Eastern Time (US & Canada)', 'America/Halifax' => '(UTC-4) Atlantic Time (Canada)', 'America/Anchorage' => '(UTC-9) Alaska (US & Canada)', 'Pacific/Honolulu' => '(UTC-10) Hawaii (US)', 'Pacific/Samoa' => '(UTC-11) Midway Island, Samoa', 'Etc/GMT-12' => '(UTC-12) Eniwetok, Kwajalein', 'Canada/Newfoundland' => '(UTC-3:30) Canada/Newfoundland', 'America/Buenos_Aires' => '(UTC-3) Brasilia, Buenos Aires, Georgetown', 'Atlantic/South_Georgia' => '(UTC-2) Mid-Atlantic', 'Atlantic/Azores' => '(UTC-1) Azores, Cape Verde Is.', 'Europe/London' => 'Greenwich Mean Time (Lisbon, London)', 'Europe/Berlin' => '(UTC+1) Amsterdam, Berlin, Paris, Rome, Madrid', 'Europe/Athens' => '(UTC+2) Athens, Helsinki, Istanbul, Cairo, E. Europe', 'Europe/Moscow' => '(UTC+3) Baghdad, Kuwait, Nairobi, Moscow', 'Iran' => '(UTC+3:30) Tehran', 'Asia/Dubai' => '(UTC+4) Abu Dhabi, Kazan, Muscat', 'Asia/Kabul' => '(UTC+4:30) Kabul', 'Asia/Yekaterinburg' => '(UTC+5) Islamabad, Karachi, Tashkent', 'Asia/Dili' => '(UTC+5:30) Bombay, Calcutta, New Delhi', 'Asia/Katmandu' => '(UTC+5:45) Nepal', 'Asia/Omsk' => '(UTC+6) Almaty, Dhaka', 'India/Cocos' => '(UTC+6:30) Cocos Islands, Yangon', 'Asia/Krasnoyarsk' => '(UTC+7) Bangkok, Jakarta, Hanoi', 'Asia/Hong_Kong' => '(UTC+8) Beijing, Hong Kong, Singapore, Taipei', 'Asia/Tokyo' => '(UTC+9) Tokyo, Osaka, Sapporto, Seoul, Yakutsk', 'Australia/Adelaide' => '(UTC+9:30) Adelaide, Darwin', 'Australia/Sydney' => '(UTC+10) Brisbane, Melbourne, Sydney, Guam', 'Asia/Magadan' => '(UTC+11) Magadan, Soloman Is., New Caledonia', 'Pacific/Auckland' => '(UTC+12) Fiji, Kamchatka, Marshall Is., Wellington')));
// Init default locale
$localeObject = Zend_Registry::get('Locale');
$languages = Zend_Locale::getTranslationList('language', $localeObject);
$territories = Zend_Locale::getTranslationList('territory', $localeObject);
$localeMultiOptions = array();
foreach (array_keys(Zend_Locale::getLocaleList()) as $key) {
$languageName = null;
if (!empty($languages[$key])) {
$languageName = $languages[$key];
} else {
$tmpLocale = new Zend_Locale($key);
$region = $tmpLocale->getRegion();
$language = $tmpLocale->getLanguage();
if (!empty($languages[$language]) && !empty($territories[$region])) {
$languageName = $languages[$language] . ' (' . $territories[$region] . ')';
}
}
if ($languageName) {
$localeMultiOptions[$key] = $languageName . ' [' . $key . ']';
}
}
$localeMultiOptions = array_merge(array('auto' => '[Automatic]'), $localeMultiOptions);
$this->addElement('Select', 'locale', array('label' => 'Default Locale', 'multiOptions' => $localeMultiOptions, 'value' => 'auto', 'disableTranslator' => true));
// init submit
$this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true));
}
示例9: datePicker
/**
* Create a jQuery UI Widget Date Picker
*
* @link http://docs.jquery.com/UI/Datepicker
* @param string $id
* @param string $value
* @param array $params jQuery Widget Parameters
* @param array $attribs HTML Element Attributes
* @return string
*/
public function datePicker($id, $value = null, array $params = array(), array $attribs = array())
{
$attribs = $this->_prepareAttributes($id, $value, $attribs);
if (Zend_Registry::isRegistered('Zend_Locale')) {
if (!isset($params['dateFormat'])) {
$params['dateFormat'] = self::resolveZendLocaleToDatePickerFormat();
}
$days = Zend_Locale::getTranslationList('Days');
if (!isset($params['dayNames'])) {
$params['dayNames'] = array_values($days['format']['wide']);
}
if (!isset($params['dayNamesShort'])) {
$params['dayNamesShort'] = array_values($days['format']['abbreviated']);
}
if (!isset($params['dayNamesMin'])) {
$params['dayNamesMin'] = array_values($days['stand-alone']['narrow']);
}
$months = Zend_Locale::getTranslationList('Months');
if (!isset($params['monthNames'])) {
$params['monthNames'] = array_values($months['stand-alone']['wide']);
}
if (!isset($params['monthNamesShort'])) {
$params['monthNamesShort'] = array_values($months['stand-alone']['narrow']);
}
}
// TODO: Allow translation of DatePicker Text Values to get this action from client to server
$params = ZendX_JQuery::encodeJson($params);
$js = sprintf('%s("#%s").datepicker(%s);', ZendX_JQuery_View_Helper_JQuery::getJQueryHandler(), $attribs['id'], $params);
$this->jquery->addOnLoad($js);
return $this->view->formText($id, $value, $attribs);
}
示例10: getNameByLanguageAndId
public function getNameByLanguageAndId($language, $id)
{
static $terr = array();
if (!isset($terr[$language])) {
$terr[$language] = Zend_Locale::getTranslationList('Territory', $language, '2');
}
return $terr[$language][$id];
}
示例11: getCountries
/**
* {@inheritdoc}
*/
public function getCountries($language)
{
$countries = \Zend_Locale::getTranslationList('territory', $language, 2);
if (is_array($countries)) {
asort($countries);
}
return $countries;
}
示例12: init
public function init()
{
parent::init();
translate('-- Select a Language --');
$this->addMultiOption(0, '-- Select a Language --');
$this->addMultiOptions(Zend_Locale::getTranslationList('language', Zend_Registry::get('Zend_Locale')));
asort($this->options);
}
示例13: getCountryLanguages
/**
* {@inheritdoc}
*/
public function getCountryLanguages($language)
{
$languages = \Zend_Locale::getTranslationList('language', $language, 2);
if (is_array($languages)) {
asort($languages);
}
return $languages;
}
示例14: __construct
public function __construct()
{
Loader::library('3rdparty/Zend/Locale');
$countries = Zend_Locale::getTranslationList('territory', Localization::activeLocale(), 2);
// unset invalid countries
unset($countries['SU'], $countries['ZZ'], $countries['IM'], $countries['JE'], $countries['VD']);
asort($countries, SORT_LOCALE_STRING);
$this->countries = $countries;
}
示例15: init
public function init()
{
parent::init();
// Add currencies
$locale = Zend_Registry::get('Zend_Translate')->getLocale();
$this->_currencies = $currencies = Zend_Locale::getTranslationList('NameToCurrency', $locale);
uksort($currencies, array($this, '_orderCurrencies'));
$this->addElement('Select', 'unit', array('label' => 'Currency Type', 'multiOptions' => $currencies, 'value' => 'USD'));
}