本文整理汇总了PHP中Zend_Locale_Data::getList方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Locale_Data::getList方法的具体用法?PHP Zend_Locale_Data::getList怎么用?PHP Zend_Locale_Data::getList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Locale_Data
的用法示例。
在下文中一共展示了Zend_Locale_Data::getList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
// Send default settings according to locale
$locale = i18n::get_locale();
$symbols = Zend_Locale_Data::getList($locale, 'symbols');
$currency = Currency::config()->currency_symbol;
$decimals = $symbols['decimal'];
$thousands = $decimals == ',' ? ' ' : ',';
// Accouting needs to be initialized globally
FormExtraJquery::include_accounting();
Requirements::customScript(<<<EOT
window.accounting.settings = {
currency: {
symbol : "{$currency}",
format: "%s%v",
decimal : "{$decimals}",
thousand: "{$thousands}",
precision : 2
},
number: {
precision : 0,
thousand: "{$thousands}",
decimal : "{$decimals}"
}
}
EOT
, 'accountingInit');
}
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-form-extras,代码行数:28,代码来源:FormExtraLeftAndMainExtension.php
示例2: _toHtml
protected function _toHtml()
{
$localeCode = Mage::app()->getLocale()->getLocaleCode();
// get days names
$days = Zend_Locale_Data::getList($localeCode, 'days');
$this->assign('days', array('wide' => Zend_Json::encode(array_values($days['format']['wide'])), 'abbreviated' => Zend_Json::encode(array_values($days['format']['abbreviated']))));
// get months names
$months = Zend_Locale_Data::getList($localeCode, 'months');
$this->assign('months', array('wide' => Zend_Json::encode(array_values($months['format']['wide'])), 'abbreviated' => Zend_Json::encode(array_values($months['format']['abbreviated']))));
// get "today" and "week" words
$this->assign('today', Zend_Json::encode(Zend_Locale_Data::getContent($localeCode, 'relative', 0)));
$this->assign('week', Zend_Json::encode(Zend_Locale_Data::getContent($localeCode, 'field', 'week')));
// get "am" & "pm" words
$this->assign('am', Zend_Json::encode(Zend_Locale_Data::getContent($localeCode, 'am')));
$this->assign('pm', Zend_Json::encode(Zend_Locale_Data::getContent($localeCode, 'pm')));
// get first day of week and weekend days
$this->assign('firstDay', (int) Mage::getStoreConfig('general/locale/firstday'));
$this->assign('weekendDays', Zend_Json::encode((string) Mage::getStoreConfig('general/locale/weekend')));
// define default format and tooltip format
$this->assign('defaultFormat', Zend_Json::encode(Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM)));
$this->assign('toolTipFormat', Zend_Json::encode(Mage::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_LONG)));
// get days and months for en_US locale - calendar will parse exactly in this locale
$days = Zend_Locale_Data::getList('en_US', 'days');
$months = Zend_Locale_Data::getList('en_US', 'months');
$enUS = new stdClass();
$enUS->m = new stdClass();
$enUS->m->wide = array_values($months['format']['wide']);
$enUS->m->abbr = array_values($months['format']['abbreviated']);
$this->assign('enUS', Zend_Json::encode($enUS));
return parent::_toHtml();
}
示例3: initVariables
public static function initVariables()
{
$locale = i18n::get_locale();
$symbols = Zend_Locale_Data::getList($locale, 'symbols');
self::$_decimals = $symbols['decimal'];
self::$_thousands = self::$_decimals == ',' ? ' ' : ',';
}
示例4: init
public function init()
{
$this->setTitle('Language Pack')->setDescription('Upload a modified language pack. This will overwrite any language entries already in a language file.')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));
$languageList = Zend_Locale_Data::getList('en', 'language');
$territoryList = Zend_Locale_Data::getList('en', 'territory');
$languageNameList = array();
foreach (array_keys(Zend_Locale::getLocaleList()) as $localeCode) {
$localeArray = explode('_', $localeCode);
$locale = array_shift($localeArray);
$territory = array_shift($localeArray);
if (isset($languageList[$locale]) && !empty($languageList[$locale])) {
$languageNameList[$localeCode] = $languageList[$locale];
if (isset($territoryList[$territory]) && !empty($territoryList[$territory])) {
$languageNameList[$localeCode] .= " ({$territoryList[$territory]})";
}
$languageNameList[$localeCode] .= " [{$localeCode}]";
}
}
asort($languageNameList);
$this->addElement('Select', 'locale', array('label' => 'Language', 'description' => 'Which language will this language pack be applied to?', 'multiOptions' => $languageNameList));
$this->addElement('File', 'file', array('label' => 'Language File', 'description' => 'Upload a language CSV file.', 'required' => true));
// Init submit
$this->addElement('Button', 'submit', array('label' => 'Upload', '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')));
}
示例5: indexAction
public function indexAction()
{
$this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('core_footer');
// Languages
$translate = Zend_Registry::get('Zend_Translate');
$languageList = $translate->getList();
//$currentLocale = Zend_Registry::get('Locale')->__toString();
// Prepare default langauge
$defaultLanguage = Engine_Api::_()->getApi('settings', 'core')->getSetting('core.locale.locale', 'en');
if (!in_array($defaultLanguage, $languageList)) {
if ($defaultLanguage == 'auto' && isset($languageList['en'])) {
$defaultLanguage = 'en';
} else {
$defaultLanguage = null;
}
}
// Prepare language name list
$languageNameList = array();
$languageDataList = Zend_Locale_Data::getList(null, 'language');
$territoryDataList = Zend_Locale_Data::getList(null, 'territory');
foreach ($languageList as $localeCode) {
$languageNameList[$localeCode] = Zend_Locale::getTranslation($localeCode, 'language', $localeCode);
if (empty($languageNameList[$localeCode])) {
list($locale, $territory) = explode('_', $localeCode);
$languageNameList[$localeCode] = "{$territoryDataList[$territory]} {$languageDataList[$locale]}";
}
}
$languageNameList = array_merge(array($defaultLanguage => $defaultLanguage), $languageNameList);
$this->view->languageNameList = $languageNameList;
}
示例6: getJsPriceFormat
/**
* Functions returns array with price formating info for js function
* formatCurrency in js/varien/js.js
*
* @return array
*/
public function getJsPriceFormat()
{
$format = Zend_Locale_Data::getContent($this->getLocaleCode(), 'currencynumber');
$symbols = Zend_Locale_Data::getList($this->getLocaleCode(), 'symbols');
$pos = strpos($format, ';');
if ($pos !== false) {
$format = substr($format, 0, $pos);
}
$format = preg_replace("/[^0\\#\\.,]/", "", $format);
$totalPrecision = 0;
$decimalPoint = strpos($format, '.');
if ($decimalPoint !== false) {
$totalPrecision = strlen($format) - (strrpos($format, '.') + 1);
} else {
$decimalPoint = strlen($format);
}
//hook for changing precision
$totalPrecision = VF_Currency_Model_Directory_Currency::PRECISION;
$requiredPrecision = $totalPrecision;
$temp = substr($format, $decimalPoint);
$pos = strpos($temp, '#');
if ($pos !== false) {
$requiredPrecision = strlen($temp) - $pos - $totalPrecision;
}
$group = 0;
if (strrpos($format, ',') !== false) {
$group = $decimalPoint - strrpos($format, ',') - 1;
} else {
$group = strrpos($format, '.');
}
$integerRequired = strpos($format, '.') - strpos($format, '0');
$result = array('pattern' => Mage::app()->getStore()->getCurrentCurrency()->getOutputFormat(), 'precision' => $totalPrecision, 'requiredPrecision' => $requiredPrecision, 'decimalSymbol' => $symbols['decimal'], 'groupSymbol' => $symbols['group'], 'groupLength' => $group, 'integerRequired' => $integerRequired);
return $result;
}
示例7: indexAction
public function indexAction()
{
if (Engine_Api::_()->user()->getViewer()->getIdentity()) {
return $this->_helper->redirector->gotoRoute(array('action' => 'home'), 'user_general', true);
}
/*
if (isset($_SESSION['skip_registration'])) {
return $this -> _helper -> redirector -> gotoRoute(array(), 'user_home', true);
}
*/
// Languages
$translate = Zend_Registry::get('Zend_Translate');
$languageList = $translate->getList();
// Prepare default langauge
$defaultLanguage = Engine_Api::_()->getApi('settings', 'core')->getSetting('core.locale.locale', 'en');
if (!in_array($defaultLanguage, $languageList)) {
if ($defaultLanguage == 'auto' && isset($languageList['en'])) {
$defaultLanguage = 'en';
} else {
$defaultLanguage = null;
}
}
// Prepare language name list
$languageNameList = array();
$languageDataList = Zend_Locale_Data::getList(null, 'language');
$territoryDataList = Zend_Locale_Data::getList(null, 'territory');
foreach ($languageList as $localeCode) {
$languageNameList[$localeCode] = Engine_String::ucfirst(Zend_Locale::getTranslation($localeCode, 'language', $localeCode));
if (empty($languageNameList[$localeCode])) {
if (false !== strpos($localeCode, '_')) {
list($locale, $territory) = explode('_', $localeCode);
} else {
$locale = $localeCode;
$territory = null;
}
if (isset($territoryDataList[$territory]) && isset($languageDataList[$locale])) {
$languageNameList[$localeCode] = $territoryDataList[$territory] . ' ' . $languageDataList[$locale];
} else {
if (isset($territoryDataList[$territory])) {
$languageNameList[$localeCode] = $territoryDataList[$territory];
} else {
if (isset($languageDataList[$locale])) {
$languageNameList[$localeCode] = $languageDataList[$locale];
} else {
continue;
}
}
}
}
}
$languageNameList = array_merge(array($defaultLanguage => $defaultLanguage), $languageNameList);
ksort($languageNameList);
$this->view->languageNameList = $languageNameList;
$this->_helper->layout->disableLayout();
// Render
//$this -> _helper -> content
//-> setNoRender()
// -> setEnabled();
}
示例8: getDaysWeek
/**
* @param string|null|Zend_Locale $locale
* @param string $type
* @throws InvalidArgumentException
* @return array
*/
public static function getDaysWeek($locale, $type = 'wide')
{
if (!in_array($type, array('wide', 'abbreviated'))) {
throw new InvalidArgumentException("Tipo inválido {$type}.");
}
$values = Zend_Locale_Data::getList($locale, 'day', array("gregorian", "format", $type));
return $values;
}
示例9: formTinyMceYN
public function formTinyMceYN($name, $value = null, $attribs = null)
{
// Disable for mobile browsers
$ua = $_SERVER['HTTP_USER_AGENT'];
if (preg_match('/Mobile/i', $ua) || preg_match('/Opera Mini/i', $ua) || preg_match('/NokiaN/i', $ua)) {
return $this->formTextarea($name, $value, $attribs);
}
$info = $this->_getInfo($name, $value, $attribs);
extract($info);
// name, value, attribs, options, listsep, disable
$disabled = '';
if ($disable) {
$disabled = ' disabled="disabled"';
}
if (Zend_Registry::isRegistered('Locale')) {
$locale = Zend_Registry::get('Locale');
if (method_exists($locale, '__toString')) {
$locale = $locale->__toString();
} else {
$locale = (string) $locale;
}
$localeData = Zend_Locale_Data::getList($locale, 'layout');
$directionality = @$localeData['characters'] == 'right-to-left' ? 'rtl' : 'ltr';
//Checking SE version
$manifest = Zend_Registry::get('Engine_Manifest');
if (version_compare($manifest['core']['package']['version'], '4.7.0', '<')) {
$this->view->tinyMceYN()->language = $locale;
$this->view->tinyMceYN()->directionality = $directionality;
} else {
$this->view->tinyMceYN1()->language = $locale;
$this->view->tinyMceYN1()->directionality = $directionality;
}
}
if (empty($attribs['rows'])) {
$attribs['rows'] = (int) $this->rows;
}
if (empty($attribs['cols'])) {
$attribs['cols'] = (int) $this->cols;
}
if (isset($attribs['editorOptions'])) {
if ($attribs['editorOptions'] instanceof Zend_Config) {
$attribs['editorOptions'] = $attribs['editorOptions']->toArray();
}
if (version_compare($manifest['core']['package']['version'], '4.7.0', '<')) {
$this->view->tinyMceYN()->setOptions($attribs['editorOptions']);
} else {
$this->view->tinyMceYN1()->setOptions($attribs['editorOptions']);
}
unset($attribs['editorOptions']);
}
if (version_compare($manifest['core']['package']['version'], '4.7.0', '<')) {
$this->view->tinyMceYN()->render();
} else {
$this->view->tinyMceYN1()->render();
}
$xhtml = '<textarea rows=24, cols=80, style="width:553px;" name="' . $this->view->escape($name) . '"' . ' id="' . $this->view->escape($id) . '"' . $disabled . $this->_htmlAttribs($attribs) . '>' . $this->view->escape($value) . '</textarea>';
return $xhtml;
}
示例10: setTimeZone
/**
* Set default time zone in the config file
*
* @param string The default time zone
* @throw USVN_Exception
*/
public static function setTimeZone($timezone)
{
$availableTimezones = Zend_Locale_Data::getList("en", "WindowsToTimezone");
if (array_key_exists($timezone, $availableTimezones)) {
$config = new USVN_Config_Ini(USVN_CONFIG_FILE, USVN_CONFIG_SECTION);
$config->timezone = $timezone;
$config->save();
} else {
throw new USVN_Exception(T_("Invalid timezone"));
}
}
示例11: localeDateTime
public function localeDateTime($format, $locale)
{
if (is_null($lang)) {
$lang = ZFE_Core::getLanguage();
}
$dt = new Zend_Date($this->getTimestamp());
$formats = Zend_Locale_Data::getList($lang, 'datetime');
if (isset($formats[$format])) {
$format = $formats[$format];
}
return $dt->toString($format, null, $lang);
}
示例12: __construct
public function __construct($name, $title = null, $value = '', $maxLength = null, $form = null)
{
parent::__construct($name, $title, $value, $maxLength, $form);
$this->setAlias(MaskedInputField::ALIAS_DECIMAL);
$this->setDigits(2);
$this->setRightAlign(false);
// Some locale use "," as radix
$locale = i18n::get_locale();
$symbols = Zend_Locale_Data::getList($locale, 'symbols');
if (!empty($symbols) && $symbols['decimal'] == ',') {
$this->setRadixPoint(',');
}
}
示例13: indexAction
public function indexAction()
{
$this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('core_footer');
// Languages
$translate = Zend_Registry::get('Zend_Translate');
$languageList = $translate->getList();
//$currentLocale = Zend_Registry::get('Locale')->__toString();
// Prepare default langauge
$defaultLanguage = Engine_Api::_()->getApi('settings', 'core')->getSetting('core.locale.locale', 'en');
if (!in_array($defaultLanguage, $languageList)) {
if ($defaultLanguage == 'auto' && isset($languageList['en'])) {
$defaultLanguage = 'en';
} else {
$defaultLanguage = null;
}
}
// Prepare language name list
$languageNameList = array();
$languageDataList = Zend_Locale_Data::getList(null, 'language');
$territoryDataList = Zend_Locale_Data::getList(null, 'territory');
foreach ($languageList as $localeCode) {
$languageNameList[$localeCode] = Engine_String::ucfirst(Zend_Locale::getTranslation($localeCode, 'language', $localeCode));
if (empty($languageNameList[$localeCode])) {
if (false !== strpos($localeCode, '_')) {
list($locale, $territory) = explode('_', $localeCode);
} else {
$locale = $localeCode;
$territory = null;
}
if (isset($territoryDataList[$territory]) && isset($languageDataList[$locale])) {
$languageNameList[$localeCode] = $territoryDataList[$territory] . ' ' . $languageDataList[$locale];
} else {
if (isset($territoryDataList[$territory])) {
$languageNameList[$localeCode] = $territoryDataList[$territory];
} else {
if (isset($languageDataList[$locale])) {
$languageNameList[$localeCode] = $languageDataList[$locale];
} else {
continue;
}
}
}
}
}
$languageNameList = array_merge(array($defaultLanguage => $defaultLanguage), $languageNameList);
$this->view->languageNameList = $languageNameList;
// Get affiliate code
$this->view->affiliateCode = Engine_Api::_()->getDbtable('settings', 'core')->core_affiliate_code;
}
示例14: parseZendCurrencyFormat
/**
* Parses a Zend_Currency & Zend_Locale into a NostoCurrency object.
*
* REQUIRES Zend Framework (version 1) to be available.
*
* @param string $currencyCode the 3-letter ISO 4217 currency code.
* @param Zend_Currency $zendCurrency the zend currency object.
* @return NostoCurrency the parsed nosto currency object.
*
* @throws NostoInvalidArgumentException
*/
public function parseZendCurrencyFormat($currencyCode, Zend_Currency $zendCurrency)
{
try {
$format = Zend_Locale_Data::getContent($zendCurrency->getLocale(), 'currencynumber');
$symbols = Zend_Locale_Data::getList($zendCurrency->getLocale(), 'symbols');
// Remove extra part, e.g. "¤ #,##0.00; (¤ #,##0.00)" => "¤ #,##0.00".
if (($pos = strpos($format, ';')) !== false) {
$format = substr($format, 0, $pos);
}
// Check if the currency symbol is before or after the amount.
$symbolPosition = strpos(trim($format), '¤') === 0 ? NostoCurrencySymbol::SYMBOL_POS_LEFT : NostoCurrencySymbol::SYMBOL_POS_RIGHT;
// Remove all other characters than "0", "#", "." and ",",
$format = preg_replace('/[^0\\#\\.,]/', '', $format);
// Calculate the decimal precision.
$precision = 0;
if (($decimalPos = strpos($format, '.')) !== false) {
$precision = strlen($format) - (strrpos($format, '.') + 1);
} else {
$decimalPos = strlen($format);
}
$decimalFormat = substr($format, $decimalPos);
if (($pos = strpos($decimalFormat, '#')) !== false) {
$precision = strlen($decimalFormat) - $pos - $precision;
}
// Calculate the group length.
if (strrpos($format, ',') !== false) {
$groupLength = $decimalPos - strrpos($format, ',') - 1;
} else {
$groupLength = strrpos($format, '.');
}
// If the symbol is missing for the current locale, use the ISO code.
$currencySymbol = $zendCurrency->getSymbol();
if (is_null($currencySymbol)) {
$currencySymbol = $currencyCode;
}
return new NostoCurrency(new NostoCurrencyCode($currencyCode), new NostoCurrencySymbol($currencySymbol, $symbolPosition), new NostoCurrencyFormat($symbols['group'], $groupLength, $symbols['decimal'], $precision));
} catch (Zend_Exception $e) {
throw new NostoInvalidArgumentException($e);
}
}
示例15: getFormat
/**
*
* @return array
*/
public function getFormat()
{
$row = $this->getData();
$currency = $this->getCurrency();
$position = $row['position'];
if ($position == 8) {
// Standard
$position = $currency->toCurrency(1);
$position = strpos($position, $currency->getSymbol());
if ($position) {
$position = 'Right';
} else {
$position = 'Left';
}
} elseif ($position == 16) {
$position = 'Right';
} else {
$position = 'Left';
}
$symbols = Zend_Locale_Data::getList($row['format'], 'symbols');
return array('precision' => $row['currency_precision'], 'requiredPrecision' => 2, 'integerRequired' => 1, 'decimalSymbol' => $symbols['decimal'], 'groupSymbol' => $symbols['group'], 'groupLength' => 3, 'position' => $position, 'symbol' => null === $currency->getSymbol() ? $currency->getShortName() : $currency->getSymbol(), 'shortName' => $currency->getShortName(), 'name' => $currency->getName(), 'display' => $row['display']);
}