本文整理汇总了PHP中Zend_Locale_Data类的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Locale_Data类的具体用法?PHP Zend_Locale_Data怎么用?PHP Zend_Locale_Data使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Zend_Locale_Data类的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: _getFormat
/**
* Retrieve date format
*
* @return string
*/
protected function _getFormat()
{
$format = $this->getColumn()->getFormat();
if (!$format) {
if (is_null(self::$_format)) {
try {
$localeCode = $this->_localeResolver->getLocaleCode();
$localeData = new \Zend_Locale_Data();
switch ($this->getColumn()->getPeriodType()) {
case 'month':
self::$_format = $localeData->getContent($localeCode, 'dateitem', 'yM');
break;
case 'year':
self::$_format = $localeData->getContent($localeCode, 'dateitem', 'y');
break;
default:
self::$_format = $this->_localeDate->getDateFormat(\Magento\Framework\Stdlib\DateTime\TimezoneInterface::FORMAT_TYPE_MEDIUM);
break;
}
} catch (\Exception $e) {
}
}
$format = self::$_format;
}
return $format;
}
示例3: _getFormat
/**
* Retrieve date format
*
* @return string
*/
protected function _getFormat()
{
$format = $this->getColumn()->getFormat();
if (!$format) {
if (is_null(self::$_format)) {
try {
$localeCode = Mage::app()->getLocale()->getLocaleCode();
$localeData = new Zend_Locale_Data();
switch ($this->getColumn()->getPeriodType()) {
case 'month':
self::$_format = $localeData->getContent($localeCode, 'dateitem', 'yM');
break;
case 'year':
self::$_format = $localeData->getContent($localeCode, 'dateitem', 'y');
break;
default:
self::$_format = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM);
break;
}
} catch (Exception $e) {
}
}
$format = self::$_format;
}
return $format;
}
示例4: _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();
}
示例5: getDisplayValue
/**
*
*/
public function getDisplayValue($pa_options = null)
{
if (caGetOption('returnAsDecimalWithCurrencySpecifier', $pa_options, false)) {
return $this->ops_currency_specifier . ' ' . $this->opn_value;
}
if (Zend_Registry::isRegistered("Zend_Locale")) {
$o_locale = Zend_Registry::get('Zend_Locale');
} else {
$o_locale = new Zend_Locale('en_US');
}
$vs_format = Zend_Locale_Data::getContent($o_locale, 'currencynumber');
// this returns a string like '50,00 ¤' for locale de_DE
$vs_decimal_with_placeholder = Zend_Locale_Format::toNumber($this->opn_value, array('locale' => $locale, 'number_format' => $vs_format, 'precision' => 2));
// if the currency placeholder is the first character, for instance in en_US locale ($10), insert a space.
// this has to be done because we don't print "$10" (which is expected in the locale rules) but "USD 10" ... and that looks nicer with an additional space.
if (substr($vs_decimal_with_placeholder, 0, 2) == '¤') {
// for whatever reason '¤' has length 2
$vs_decimal_with_placeholder = str_replace('¤', '¤ ', $vs_decimal_with_placeholder);
}
// insert currency which is not locale-dependent in our case
$vs_val = str_replace('¤', $this->ops_currency_specifier, $vs_decimal_with_placeholder);
if (($vs_to_currency = caGetOption('displayCurrencyConversion', $pa_options, false)) && $this->ops_currency_specifier != $vs_to_currency) {
$vs_val .= " (" . _t("~%1", caConvertCurrencyValue($this->ops_currency_specifier . ' ' . $this->opn_value, $vs_to_currency)) . ")";
}
return $vs_val;
}
示例6: 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')));
}
示例7: getDisplayValue
/**
*
*/
public function getDisplayValue($pa_options = null)
{
if (caGetOption('returnAsDecimalWithCurrencySpecifier', $pa_options, false)) {
return $this->ops_currency_specifier . ' ' . $this->opn_value;
}
if (Zend_Registry::isRegistered("Zend_Locale")) {
$o_locale = Zend_Registry::get('Zend_Locale');
} else {
$o_locale = new Zend_Locale('en_US');
}
$vs_format = Zend_Locale_Data::getContent($o_locale, 'currencynumber');
// this returns a string like '50,00 ¤' for locale de_DE
$vs_decimal_with_placeholder = Zend_Locale_Format::toNumber($this->opn_value, array('locale' => $o_locale, 'number_format' => $vs_format, 'precision' => 2));
// if the currency placeholder is the first character, for instance in en_US locale ($10), insert a space.
// we do this because we don't print "$10" (which is expected in the Zend locale rules) but "USD 10" ... and that looks nicer with an additional space.
// we also replace the weird multibyte nonsense Zend uses as placeholder with something more reasonable so that
// whatever we output here isn't rejected if thrown into parseValue() again
if (substr($vs_decimal_with_placeholder, 0, 2) == "¤") {
// '¤' has length 2
$vs_decimal_with_placeholder = str_replace("¤", '% ', $vs_decimal_with_placeholder);
} elseif (substr($vs_decimal_with_placeholder, -2) == "¤") {
// placeholder at the end
$vs_decimal_with_placeholder = preg_replace("![^\\d\\,\\.]!", "", $vs_decimal_with_placeholder) . " %";
}
// insert currency which is not locale-dependent in our case
$vs_val = str_replace('%', $this->ops_currency_specifier, $vs_decimal_with_placeholder);
if (($vs_to_currency = caGetOption('displayCurrencyConversion', $pa_options, false)) && $this->ops_currency_specifier != $vs_to_currency) {
$vs_val .= " (" . _t("~%1", caConvertCurrencyValue($this->ops_currency_specifier . ' ' . $this->opn_value, $vs_to_currency)) . ")";
}
return $vs_val;
}
示例8: on_start
public function on_start()
{
$this->error = Loader::helper('validation/error');
if (USER_REGISTRATION_WITH_EMAIL_ADDRESS == true) {
$this->set('uNameLabel', t('Email Address'));
} else {
$this->set('uNameLabel', t('Username'));
}
$txt = Loader::helper('text');
if (strlen($_GET['uName'])) {
// pre-populate the username if supplied, if its an email address with special characters the email needs to be urlencoded first,
$this->set("uName", trim($txt->email($_GET['uName'])));
}
$languages = array();
$locales = array();
if (Config::get('LANGUAGE_CHOOSE_ON_LOGIN')) {
Loader::library('3rdparty/Zend/Locale');
Loader::library('3rdparty/Zend/Locale/Data');
$languages = Localization::getAvailableInterfaceLanguages();
if (count($languages) > 0) {
array_unshift($languages, 'en_US');
}
$locales = array('' => t('** Default'));
Zend_Locale_Data::setCache(Cache::getLibrary());
foreach ($languages as $lang) {
$loc = new Zend_Locale($lang);
$locales[$lang] = Zend_Locale::getTranslation($loc->getLanguage(), 'language', ACTIVE_LOCALE);
}
}
$this->locales = $locales;
$this->set('locales', $locales);
$this->openIDReturnTo = BASE_URL . View::url("/login", "complete_openid");
}
示例9: 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;
}
示例10: preDispatch
public function preDispatch(Zend_Controller_Request_Abstract $request)
{
$view = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer')->view;
$locale = Zend_Registry::get('Zend_Locale');
$view->locale = key($locale->getDefault());
$view->date_format = Zend_Locale_Data::getContent($view->locale, 'date');
}
示例11: 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;
}
示例12: initVariables
public static function initVariables()
{
$locale = i18n::get_locale();
$symbols = Zend_Locale_Data::getList($locale, 'symbols');
self::$_decimals = $symbols['decimal'];
self::$_thousands = self::$_decimals == ',' ? ' ' : ',';
}
示例13: 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();
}
示例14: 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;
}
示例15: 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;
}