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'); }
/** * 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; }
/** * 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; }
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(); }
/** * */ 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; }
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'))); }
/** * */ 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; }
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"); }
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; }
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'); }
/** * 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; }
public static function initVariables() { $locale = i18n::get_locale(); $symbols = Zend_Locale_Data::getList($locale, 'symbols'); self::$_decimals = $symbols['decimal']; self::$_thousands = self::$_decimals == ',' ? ' ' : ','; }
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(); }
/** * @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; }
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; }
/** * @param string $backend * @param array $frontendOptions * @param array $backendOptions * @return Zend_Cache_Core */ public function factory($backend, $frontendOptions = [], $backendOptions = []) { $backend = $this->createBackend($backend, $backendOptions); $cacheCore = $this->createCacheCore($frontendOptions); $cacheCore->setBackend($backend); \Zend_Locale_Data::setCache($cacheCore); \Zend_Db_Table_Abstract::setDefaultMetadataCache($cacheCore); return $cacheCore; }
public function testGetLocale() { $objectManager = \Magento\Framework\App\ObjectManager::getInstance(); \Zend_Locale_Data::removeCache(); $this->assertNull(\Zend_Locale_Data::getCache()); $model = $objectManager->create('Magento\\Framework\\Locale\\ResolverInterface', ['locale' => 'some_locale']); $this->assertInstanceOf('Zend_Locale', $model->getLocale()); $this->assertInstanceOf('Zend_Cache_Core', \Zend_Locale_Data::getCache()); }
public function setup() { if (Zend_Registry::isRegistered('Zend_Locale')) { $registry = Zend_Registry::getInstance(); unset($registry['Zend_Locale']); } Zend_Locale_Data::removeCache(); $this->_locale = setlocale(LC_ALL, 0); setlocale(LC_ALL, 'de'); }
/** * 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")); } }
/** * Class constructor * * @param array|Zend_Config $options (Optional) */ public function __construct($options = null) { if ($options instanceof Zend_Config) { $options = $options->toArray(); } if (null === $options) { $locale = Zend_Registry::get('Zend_Locale')->toString(); $dateFormat = Zend_Locale_Data::getContent($locale, 'date'); $options = array('locale' => $locale, 'date_format' => $dateFormat); } $this->setOptions($options); }
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); }
public function addAction() { $form = new Zetta_Form(Zend_Registry::get('config')->Cron->form->task); /* заполняем выпадающие списки данными */ $minute = $form->getElement('minute'); for ($i = -1; $i <= 59; $i++) { $i == -1 ? $minute->addMultiOption('*', '*') : $minute->addMultiOption($i, $i); } $hour = $form->getElement('hour'); for ($i = -1; $i <= 23; $i++) { $i == -1 ? $hour->addMultiOption('*', '*') : $hour->addMultiOption($i, sprintf('%02d', $i)); } $day = $form->getElement('day'); for ($i = 0; $i <= 31; $i++) { $i == 0 ? $day->addMultiOption('*', '*') : $day->addMultiOption($i, sprintf('%02d', $i)); } $month = $form->getElement('month'); for ($i = 0; $i <= 12; $i++) { if ($i == 0) { $month->addMultiOption('*', '*'); } else { $month_str = Zend_Locale_Data::getContent(new Zend_Locale(), 'month', array('gregorian', 'stand-alone', 'wide', intval($i))); $month->addMultiOption($i, $month_str); } } $week = $form->getElement('week_day'); $array_weekDay = array('', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun'); for ($i = 0; $i <= 7; $i++) { if ($i == 0) { $week->addMultiOption('*', '*'); } else { $week_str = Zend_Locale_Data::getContent(new Zend_Locale(), 'day', array('gregorian', 'format', 'wide', $array_weekDay[$i])); $week->addMultiOption($i, $week_str); } } if ($cron_id = $this->getParam('cron_id')) { $this->view->cron_id = $cron_id; $editData = $this->_model->fetchRow($this->_model->select()->where('cron_id = ?', $cron_id))->toArray(); $form->setDefaults($editData); } if (!sizeof($_POST) || !$form->isValid($_POST)) { $this->view->form = $form; } else { $arrayData = array('minute' => $form->getValue('minute'), 'hour' => $form->getValue('hour'), 'day' => $form->getValue('day'), 'month' => $form->getValue('month'), 'week_day' => $form->getValue('week_day'), 'task' => $form->getValue('task'), 'active' => (bool) $form->getValue('active') == true ? '1' : new Zend_Db_Expr('NULL')); if ($cron_id) { $this->_model->update($arrayData, $this->_model->getAdapter()->quoteInto('cron_id = ?', $cron_id)); } else { $this->_model->insert($arrayData); } $this->renderScript('admin/addComplete.ajax.phtml'); } }
/** * Setup zend cache directory. * * @return void */ protected function _initZendCache() { $this->bootstrap('Configuration'); $config = $this->getResource('Configuration'); $frontendOptions = array('lifetime' => 600, 'automatic_serialization' => true); $backendOptions = array('cache_dir' => $config->workspacePath . '/cache/'); $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions); Zend_Translate::setCache($cache); Zend_Locale::setCache($cache); Zend_Locale_Data::setCache($cache); Zend_Db_Table_Abstract::setDefaultMetadataCache($cache); return $cache; }
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(','); } }
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; }
/** * Returns the actual or details of available currency symbol choice, * * @param string $currency (Optional) Currency name * @param string|Zend_Locale $locale (Optional) Locale to display informations * @return string */ public function getSymbolChoice($currency = null, $locale = null) { if ($currency === null and $locale === null) { return $this->_options['symbol_choice']; } $params = self::_checkParams($currency, $locale); //Get the symbol choice $symbolChoice = Zend_Locale_Data::getContent($params['locale'], 'currencysymbolchoice', $params['currency']); if (empty($symbolChoice) === true) { $symbolChoice = Zend_Locale_Data::getContent($params['locale'], 'currencysymbolchoice', $params['name']); } if (empty($symbolChoice) === true) { return null; } return $symbolChoice; }
public function render(Zend_View_Interface $view = null) { if ($this->_fieldMeta instanceof Fields_Model_Meta && !empty($this->_fieldMeta->config['unit'])) { //$currency = new Zend_Currency($this->_fieldMeta->config['unit']); $localeObject = Zend_Registry::get('Locale'); $currencyCode = $this->_fieldMeta->config['unit']; $currencyName = Zend_Locale_Data::getContent($localeObject, 'nametocurrency', $currencyCode); $this->loadDefaultDecorators(); $this->getDecorator('Label')->setOption('optionalSuffix', ' - ' . $currencyCode)->setOption('requiredSuffix', ' - ' . $currencyCode); if ($currencyName && !$this->getDescription()) { $this->setDescription($currencyName); $this->getDecorator('Description')->setOption('placement', 'APPEND'); } } return parent::render($view); }
public function view() { 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(); Zend_Locale_Data::setCache(Cache::getLibrary()); foreach($languages as $lang) { $loc = new Zend_Locale($lang); $locales[$lang] = Zend_Locale::getTranslation($loc->getLanguage(), 'language', $lang); } $this->set('LANGUAGE_CHOOSE_ON_LOGIN', Config::get('LANGUAGE_CHOOSE_ON_LOGIN')); $this->set('LANGUAGE_MULTILINGUAL_CONTENT_ENABLED', Config::get('LANGUAGE_MULTILINGUAL_CONTENT_ENABLED')); $this->set('interfacelocales', $locales); $this->set('languages', $languages); }
public function __construct() { parent::__construct(); $this->i18n_dir = dirname(dirname(__FILE__)) . "/i18n"; $current_locale = P4A::singleton()->i18n->getLocale(); $languages = array(); foreach (scandir($this->i18n_dir) as $file) { if (substr($file, -4) == ".php") { $locale = substr($file, 0, -4); list($language_code, $region_code) = explode("_", $locale); $language_name = Zend_Locale_Data::getContent($current_locale, 'language', $language_code); $region_name = Zend_Locale_Data::getContent($current_locale, 'country', $region_code); $languages[] = array("locale" => $locale, "description" => "{$language_name} ({$region_name})"); } } $this->build("P4A_Array_Source", "languages")->setPk("locale")->load($languages); $this->build("P4A_Field", "choose_language")->setType("radio")->setValue($current_locale)->setSource($this->languages); $this->choose_language->label->setWidth(120); $this->build("P4A_Button", "apply")->implement("onclick", $this, "apply"); $this->frame->anchor($this->choose_language)->newRow()->anchorCenter($this->apply); }
/** * 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); } }