public function init() { parent::init(); try { $locale = Zend_Registry::get("Zend_Locale"); } catch (Exception $e) { $locale = new Zend_Locale("en"); } $this->view->language = $locale->getLanguage(); $this->language = $locale->getLanguage(); }
/** * Return the javascript file used to localize the datePicker component * * @param Zend_Locale $locale the given locale * @param ZendX_JQuery_View_Helper_JQuery_Container $instance the jquery helper * * @return string */ public function getDatePickerLocaleJavascriptFile(Zend_Locale $locale, $instance) { if ($instance->useUiCdn()) { $baseUri = $instance->_getJQueryLibraryBaseCdnUri(); $uiPath = $baseUri . ZendX_JQuery::CDN_SUBFOLDER_JQUERYUI . $instance->getUiVersion() . "/i18n/jquery.ui.datepicker-{$locale->getLanguage()}.js"; } else { if ($instance->useUiLocal()) { $uiPath = $instance->getUiPath() . "/i18n/jquery.ui.datepicker-{$locale->getLanguage()}.js"; } } return $uiPath; }
/** * Hook that loads the form data from $_POST or the model * * Or from whatever other source you specify here. */ protected function loadFormData() { parent::loadFormData(); if ($this->trackEngine instanceof \Gems_Tracker_Engine_StepEngineAbstract) { if ($this->trackEngine->updateRoundModelToItem($this->getModel(), $this->formData, $this->locale->getLanguage())) { if (isset($this->formData[$this->saveButtonId])) { // Disable validation & save unset($this->formData[$this->saveButtonId]); // Warn user $this->addMessage($this->_('Lists choices changed.')); } } } }
/** * Execute method * * @param string $name * @param string $type * @param array $attribs * @param string $kcfinderPath * @return string */ public function kcfinder($name, $type = 'file', array $attribs = array(), $kcfinderPath = null) { if (null !== $kcfinderPath) { self::$kcfinderPath = $kcfinderPath; } $src = self::$kcfinderPath . '?type=' . $type . '&lang=' . $this->locale->getLanguage(); if (isset($attribs['src'])) { unset($attribs['src']); } $xhtml = '<div ' . $this->_htmlAttribs($attribs) . '>'; $xhtml .= '<iframe id="' . $this->view->escape($name) . '" src="' . $src . '"></iframe>'; $xhtml .= '</div>'; return $xhtml; }
public function init() { parent::init(); if (\Zend_Registry::isRegistered('Zend_Locale')) { $this->locale = \Zend_Registry::get('Zend_Locale'); } else { $this->locale = new \Zend_Locale('en'); \Zend_Registry::set('Zend_Locale', $this->locale); } $this->view->language = $this->locale->getLanguage(); $this->language = $this->locale->getLanguage(); $this->translate = $this->initTranslation(); \Zend_View_Helper_PaginationControl::setDefaultViewPartial('partial/pagination.php'); }
/** * Changes the display of gro_valid_[after|for]_field into something readable * * @param mixed $value The value being saved * @param boolean $isNew True when a new item is being saved * @param string $name The name of the current field * @param array $context Optional, the other values being saved * @return string The value to use */ public function displayDateCalculation($value, $new, $name, array $context = array()) { $fieldBase = substr($name, 0, -5); // Strip field $validAfter = (bool) strpos($fieldBase, 'after'); // When always valid, just return nothing if ($context[$fieldBase . 'source'] == self::NO_TABLE) { return ''; } $fields = $this->getDateOptionsFor($context[$fieldBase . 'source'], $context[$fieldBase . 'id'], $this->locale->getLanguage(), $validAfter); if (isset($fields[$context[$fieldBase . 'field']])) { $field = $fields[$context[$fieldBase . 'field']]; } else { $field = $context[$fieldBase . 'field']; } if ($context[$fieldBase . 'length'] > 0) { $format = $this->_('%s plus %s %s'); } elseif ($context[$fieldBase . 'length'] < 0) { $format = $this->_('%s minus %s %s'); } else { $format = $this->_('%s'); } $units = $this->util->getTranslated()->getPeriodUnits(); if (isset($units[$context[$fieldBase . 'unit']])) { $unit = $units[$context[$fieldBase . 'unit']]; } else { $unit = $context[$fieldBase . 'unit']; } // \MUtil_Echo::track(func_get_args()); return sprintf($format, $field, abs($context[$fieldBase . 'length']), $unit); }
/** * Go directly to url */ public function toSurveyAction() { if (!$this->_initToken()) { // Default option $this->_forward('index'); return; } $language = $this->locale->getLanguage(); try { $url = $this->token->getUrl($language, $this->currentUser->getUserId() ? $this->currentUser->getUserId() : $this->token->getRespondentId()); /************************ * Optional user logout * ************************/ if ($this->currentUser->isLogoutOnSurvey()) { $this->currentUser->unsetAsCurrentUser(); } // Redirect at once header('Location: ' . $url); exit; } catch (\Gems_Tracker_Source_SurveyNotFoundException $e) { $this->addMessage(sprintf($this->_('The survey for token %s is no longer active.'), strtoupper($this->tokenId))); // Default option $this->_forward('index'); } }
/** * Creates the model * * @return \MUtil_Model_ModelAbstract */ protected function createModel() { $model = $this->token->getSurveyAnswerModel($this->locale->getLanguage()); $model->set('gto_valid_from', 'dateFormat', $this->dateFormat); $model->set('gto_completion_time', 'dateFormat', $this->dateFormat); return $model; }
/** * @throws Exception */ public function languageDetectionAction() { // Get the browser language $locale = new Zend_Locale(); $browserLanguage = $locale->getLanguage(); $languages = Tool::getValidLanguages(); // Check if the browser language is a valid frontend language if (in_array($browserLanguage, $languages)) { $language = $browserLanguage; } else { // If it is not, take the first frontend language as default $language = reset($languages); } // Get the folder of the current language (in the current site) $currentSitePath = $this->document->getRealFullPath(); $folder = Document\Page::getByPath($currentSitePath . '/' . $language); if ($folder) { $document = $this->findFirstDocumentByParentId($folder->getId()); if ($document) { $this->redirect($document->getPath() . $document->getKey()); } else { throw new Exception('No document found in your browser language'); } } else { throw new Exception('No language folder found that matches your browser language'); } }
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'))); }
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"); }
/** * Init Translation system using gettext * * @param object $locale instance of Zend_Locale * * @return void */ public function iniTranslation($locale, array $availableDomains = array()) { if (!$locale instanceof Zend_Locale) { $locale = new Zend_Locale($locale); } $localeDirPath = $this->getConfig('localeDirPath'); // init available gettext domains foreach ($availableDomains as $domain) { bindtextdomain($domain, $localeDirPath); bind_textdomain_codeset($domain, 'UTF-8'); } // set first domain has default domain $defaultDomain = array_shift($availableDomains); textdomain($defaultDomain); $localeWithEncoding = $locale . '.utf8'; // mandatory for gettext if (putenv('LANGUAGE') != $locale->getLanguage()) { throw new BaseZF_Service_GetText_Exception(sprintf('Could not set the ENV variable LANGUAGE = %s', $locale)); } if (setlocale(LC_MESSAGES, $localeWithEncoding) !== $localeWithEncoding) { throw new BaseZF_Service_GetText_Exception(sprintf('Unable to set locale "%s" to value "%s", please check installed locales on system', 'LC_MESSAGES', $localeWithEncoding)); } if (setlocale(LC_TIME, $localeWithEncoding) !== $localeWithEncoding) { throw new BaseZF_Service_GetText_Exception(sprintf('Unable to set locale "%s" to value "%s", please check installed locales on system', 'LC_TIME', $localeWithEncoding)); } return $this; }
private static function build() { # recupera idioma requisitado ou tenta descobri-lo if (!($acronym = self::lang())) { $locale = new Zend_Locale(); $acronym = $locale->getLanguage(); } # seleciona idioma solicitado/utilizado $language = []; foreach (Ao_Data_Language::$data as $lang) { if ($acronym == $lang['acronym']) { $language = $lang; break; } } # set idioma padrão se nenhum for associado if (empty($language)) { $language = Ao_Data_Language::$data[self::LANG_ID]; } # inicializa atributos $lang = new stdClass(); $lang->id = $language['id']; $lang->acronym = $language['acronym']; $lang->name = $language['name']; # return return $lang; }
/** * Constructure and setting configuration * * @param array $config * @throws Ht_Utils_PoCreater_Exception */ public function __construct($config = array()) { if (!isset($config[self::LOCAL_DIR_KEY])) { throw new Ht_Utils_PoCreater_Exception("Local path not setting !"); } if (realpath($config[self::LOCAL_DIR_KEY])) { $this->_locales_dir = realpath($config[self::LOCAL_DIR_KEY]); } else { throw new Ht_Utils_PoCreater_Exception("Local path setting up is not exists!"); } if (isset($config[self::LANGUAGE_KEY])) { if ($config[self::LANGUAGE_KEY] != "") { try { $locale = new Zend_Locale($config[self::LANGUAGE_KEY]); $this->_language = $locale->getLanguage(); } catch (Ht_Utils_PoCreater_Exception $e) { throw $e; } } } if (isset($config[self::ADAPTER_KEY]) && $config[self::ADAPTER_KEY] instanceof Zend_Db_Table_Abstract) { $this->_adapter = $config[self::ADAPTER_KEY]; } if (isset($config[self::DATA_KEY])) { $this->_data = $config[self::DATA_KEY]; } }
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)); }
/** * Try to set given locale * Throw Zend_Translate_Exception if cannot */ public function setLocale($name = null) { try { if (!$this->localeName) { $this->locale = new Zend_Locale($name); } else { $this->locale->setLocale($name); } if (array_key_exists($this->locale->getLanguage(), $this->translationsPaths)) { if (!isset($this->translate)) { $this->translate = new Zend_Translate($this->translationAdapter, $this->translationsPaths[$this->locale->getLanguage()], $this->locale->getLanguage()); } elseif ($this->translate->isAvailable($this->locale->getLanguage())) { $this->translate->setLocale($this->locale->getLanguage()); } else { $this->translate->addTranslation($this->translationsPaths[$this->locale->getLanguage()], $this->locale->getLanguage()); } } else { include_once 'Zend/Translate/Exception.php'; throw new Zend_Translate_Exception("Unsupported language"); } } catch (Zend_Exception $e) { if ($this->localeName) { $this->setLocale($this->localeName); } throw $e; } $this->localeName = $this->session->localeName = $this->locale->getLanguage() . ($this->locale->getRegion() ? "_" . $this->locale->getRegion() : ""); Zend_Registry::set('Zend_Locale', $this->locale); Zend_Locale::setDefault($this->locale); }
public function preDispatch($request) { try { $locale = new Zend_Locale(); $locale->setDefault('en'); $locale->setLocale(Zend_Locale::BROWSER); $requestedLanguage = key($locale->getBrowser()); $formatter = new Zend_Log_Formatter_Simple('%message%' . PHP_EOL); $writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'translations.log'); $writer->setFormatter($formatter); $logger = new Zend_Log($writer); $frontendOptions = array('cache_id_prefix' => 'translation', 'lifetime' => 86400, 'automatic_serialization' => true); $backendOptions = array('cache_dir' => APPLICATION_CACHE_PATH); $cache = Zend_Cache::factory('Core', 'File', $frontendOptions, $backendOptions); $options = array('adapter' => 'gettext', 'scan' => Zend_Translate::LOCALE_FILENAME, 'content' => APPLICATION_PATH . '/languages/en/en.mo', 'locale' => 'auto', 'disableNotices' => true); $translate = new Zend_Translate($options); if (!$translate->isAvailable($locale->getLanguage())) { $locale->setLocale('en'); } else { $translate->setLocale($locale); } $translate->setCache($cache); Zend_Registry::set('locale', $locale->getLanguage()); Zend_Registry::set('Zend_Translate', $translate); } catch (Exception $e) { try { $writer = new Zend_Log_Writer_Stream(APPLICATION_LOG_PATH . 'plugin-locale.log'); $logger = new Zend_Log($writer); $logger->log($e->getMessage(), Zend_Log::ERR); } catch (Exception $e) { } } }
public function init() { $controller = $this->getActionController(); if (!($requestedLocale = $controller->getRequest()->getParam('language', false))) { $local = new Zend_Locale(); $requestedLocale = $local->getLanguage(); } if (is_array($requestedLocale)) { $requestedLocale = current($requestedLocale); } $requestedLocale = strtolower($requestedLocale); try { Centurion_Db::getSingleton('translation/language')->get(array('locale' => $requestedLocale)); } catch (Centurion_Db_Table_Row_Exception_DoesNotExist $e) { $requestedLocale = Translation_Traits_Common::getDefaultLanguage(); $requestedLocale = $requestedLocale->locale; } Zend_Registry::get('Zend_Translate')->setLocale($requestedLocale); Zend_Locale::setDefault($requestedLocale); Zend_Registry::set('Zend_Locale', $requestedLocale); $options = Centurion_Db_Table_Abstract::getDefaultFrontendOptions(); if (!isset($options['cache_id_prefix'])) { $options['cache_id_prefix'] = ''; } $options['cache_id_prefix'] = $requestedLocale . '_' . $options['cache_id_prefix']; Centurion_Db_Table_Abstract::setDefaultFrontendOptions($options); //TODO: fix this when in test unit environment if (!APPLICATION_ENV === 'testing') { $this->getActionController()->getFrontController()->getParam('bootstrap')->getResource('cachemanager')->addIdPrefix($requestedLocale . '_'); } if (Centurion_Config_Manager::get('translation.global_param')) { $this->getFrontController()->getRouter()->setGlobalParam('language', $requestedLocale); } }
function init() { Zend_Registry::set('languages', array('en' => 'English', 'es' => 'Español', 'ca' => 'Català', 'gl' => 'Galego', 'eu' => 'Euskara', 'nl' => 'Nederlands', 'de' => 'Deutsch', 'fr' => 'Français', 'pt' => 'Português', 'it' => 'Italiano')); $activelangs = array('en' => 0, 'es' => 0, 'ca' => 1, 'gl' => 1, 'eu' => 1, 'nl' => 1, 'de' => 1, 'fr' => 1, 'pt' => 1, 'it' => 1); Zend_Registry::set('activelangs', $activelangs); $this->lang = $this->getRequest()->getParam("language"); if ($this->lang == null) { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $this->lang = $auth->getIdentity()->lang; } } if ($this->lang == null && isset($_COOKIE['lang'])) { $this->lang = $_COOKIE['lang']; } $locale = new Zend_Locale(); // El setLocale del Zend está malito... // uso también el nativo de php $locale->setLocale($this->lang . '_' . strtoupper($this->lang) . '.utf8'); setlocale(LC_ALL, $this->lang . '_' . strtoupper($this->lang) . '.utf8'); if (!isset($activelangs[$locale->getLanguage()])) { $locale->setLocale('es_ES.utf8'); } $this->lang = $locale->getLanguage(); $this->langtest = $activelangs[$this->lang] == 1; $options = array('scan' => Zend_Translate::LOCALE_FILENAME); $translate = new Zend_Translate('csv', APPLICATION_PATH . '/languages/', $this->lang, $options); if ($translate->isAvailable($this->lang)) { $translate->setLocale($locale); Zend_Form::setDefaultTranslator($translate); Zend_Registry::set('Zend_Translate', $translate); } else { header('Location: /es'); exit; } if ($this->langtest && (!isset($_COOKIE['langtest']) || $_COOKIE['langtest'] != "0")) { $controller = $this->getActionController(); if (isset($controller->view)) { $controller->view->extra .= " advices"; if (!$controller->view->advices) { $controller->view->advices = array(); } $controller->view->advices["langtest"] = $controller->view->translate("BetaTranslation", "/{$this->lang}/page/translate?lang={$this->lang}"); $controller->view->headScript()->appendFile('/js/jquery.advice.js'); } } }
/** * Convenience function to get the current language * * @return string */ public function getLanguage() { if (null === $this->resource) { $locale = new Zend_Locale(); return $locale->getLanguage(); } return $this->resource->getLanguage(); }
/** * Convenience function to get the language based on the * MultiLanguage resource, or in its absence based on the * locale */ public static function getLanguage() { if (Zend_Registry::isRegistered('ZFE_MultiLanguage')) { $ml = Zend_Registry::get('ZFE_MultiLanguage'); return $ml->getLanguage(); } $locale = new Zend_Locale(); return $locale->getLanguage(); }
private function resolveLocale(\Zend_Locale $locale) { $proposed = array($locale->toString(), $locale->getLanguage(), self::DEFAULT_LANG); foreach ($proposed as $lang) { if (isset(self::$trans[$lang])) { return $lang; } } }
public function _initTranslate() { $locale = new Zend_Locale(Zend_Locale::findLocale()); $localeName = $locale->getLanguage(); if (!in_array($localeName, array('en', 'ru'))) { $localeName = 'en'; } $translate = new Zend_Translate(array('adapter' => 'tmx', 'content' => APPLICATION_PATH . '/configs/lang.xml', 'locale' => $localeName)); Zend_Registry::set('Zend_Translate', $translate); }
/** * Returns available language options determined by translation resources. * * @return array * @throws Zend_Exception */ public function getLanguageOptions() { $translator = Zend_Registry::get('Zend_Translate'); $currentLocale = new Zend_Locale($translator->getLocale()); $translations = $translator->getList(); $options = array(); foreach ($translations as $language) { $options[$language] = $currentLocale->getTranslation($language, 'language', $currentLocale->getLanguage()); } return $options; }
/** * Adds rows from the model to the bridge that creates the browse table. * * Overrule this function to add different columns to the browse table, without * having to recode the core table building code. * * @param \MUtil_Model_Bridge_VerticalTableBridge $bridge * @param \MUtil_Model_ModelAbstract $model * @return void */ protected function addShowTableRows(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model) { $this->_roundData = $bridge->getRow(); if ($this->trackEngine instanceof \Gems_Tracker_Engine_StepEngineAbstract) { $this->trackEngine->updateRoundModelToItem($model, $this->_roundData, $this->locale->getLanguage()); } $bridge->addItem('gro_id_track'); $bridge->addItem('gro_id_survey'); $bridge->addItem('gro_round_description'); $bridge->addItem('gro_id_order'); $bridge->addItem('gro_icon_file'); if ($model->has('ggp_name')) { $bridge->addItem('ggp_name'); } elseif ($model->has('gro_id_relationfield')) { $bridge->addItem('gro_id_relationfield'); } $bridge->addItem($model->get('valid_after', 'value')); $this->_addIf(array('gro_valid_after_source', 'gro_valid_after_id', 'gro_valid_after_field'), $bridge, $model); if ($model->has('gro_valid_after_length', 'label')) { $bridge->addItem(array($bridge->gro_valid_after_length, ' ', $bridge->gro_valid_after_unit), $model->get('gro_valid_after_length', 'label')); } $bridge->addItem($model->get('valid_for', 'value')); $this->_addIf(array('gro_valid_for_source', 'gro_valid_for_id', 'gro_valid_for_field'), $bridge, $model); if ($model->has('gro_valid_for_length', 'label')) { $bridge->addItem(array($bridge->gro_valid_for_length, ' ', $bridge->gro_valid_for_unit), $model->get('gro_valid_after_length', 'label')); } $bridge->addItem('gro_active'); // Preven empty row when no changed events exist if ($label = $model->get('gro_changed_event', 'label')) { $bridge->addItem('gro_changed_event'); } $bridge->addItem('gro_code'); $bridge->addItem('org_specific_round'); if ($this->_roundData['org_specific_round']) { $bridge->addItem('organizations'); } $menuItem = $this->menu->find(array($this->request->getControllerKey() => $this->request->getControllerName(), $this->request->getActionKey() => 'edit')); if ($menuItem) { $bridge->tbody()->onclick = array('location.href=\'', $menuItem->toHRefAttribute($this->request), '\';'); } }
public function localeShort() { $translator = $this->view->getHelper('translate')->getTranslator(); $locale = $translator->getLocale(); if (!$translator->isAvailable($locale)) { $defaults = Zend_Locale::getDefault(); arsort($defaults); $locale = key($defaults); } $locale = new Zend_Locale($locale); return $locale->getLanguage(); }
public function _initTranslate() { $locale = new Zend_Locale(Zend_Locale::BROWSER); $translate = new Zend_Translate(array('adapter' => 'csv', 'content' => APPLICATION_PATH . '/configs/languages/lang.en', 'locale' => 'en')); $translate->addTranslation(array('content' => APPLICATION_PATH . '/configs/languages/lang.hi', 'locale' => 'hi')); if ($translate->isAvailable($locale->getLanguage())) { $translate->setLocale($locale); } else { $translate->setLocale('en'); } Zend_Registry::set('Translate', $translate); }
public function init() { // @todo fix form CSS/decorators // @todo replace fake values with real values $this->setTitle('General Settings')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array())); // Init email $this->addElement('Text', 'email', array('label' => 'Email Address', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('EmailAddress', true), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'email', array('field' => 'user_id', 'value' => $this->getItem()->getIdentity())))))); $this->email->getValidator('NotEmpty')->setMessage('Please enter a valid email address.', 'isEmpty'); $this->email->getValidator('Db_NoRecordExists')->setMessage('Someone has already registered this email address, please use another one.', 'recordFound'); // Init username $this->addElement('Text', 'username', array('label' => 'Profile Address', 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('Alnum', true), array('StringLength', true, array(4, 64)), array('Regex', true, array('/^[a-z0-9]/i')), array('Db_NoRecordExists', true, array(Engine_Db_Table::getTablePrefix() . 'users', 'username', array('field' => 'user_id', 'value' => $this->getItem()->getIdentity())))))); $this->username->getValidator('NotEmpty')->setMessage('Please enter a valid profile address.', 'isEmpty'); $this->username->getValidator('Db_NoRecordExists')->setMessage('Someone has already picked this profile address, please use another one.', 'recordFound'); $this->username->getValidator('Regex')->setMessage('Profile addresses must start with a letter.', 'regexNotMatch'); $this->username->getValidator('Alnum')->setMessage('Profile addresses must be alphanumeric.', 'notAlnum'); // Init type $this->addElement('Select', 'accountType', array('label' => 'Account Type')); // Init Facebook $facebook_enable = Engine_Api::_()->getApi('settings', 'core')->getSetting('core_facebook_enable', 'none'); if ('none' != $facebook_enable) { $and_publish = 'publish' == $facebook_enable ? ' and publish content to your Facebook wall.' : '.'; $this->addElement('Dummy', 'facebook', array('label' => 'Facebook Integration', 'description' => 'Linking your Facebook account will let you login with Facebook' . $and_publish, 'content' => User_Model_DbTable_Facebook::loginButton('Integrate with my Facebook'))); $this->addElement('Checkbox', 'facebook_id', array('label' => 'Integrate with my Facebook', 'description' => 'Facebook Integration')); } // Init timezone $this->addElement('Select', 'timezone', array('label' => 'Timezone', 'description' => 'Select the city closest to you that shares your same 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 $locale = Zend_Registry::get('Locale'); $localeMultiKeys = array_merge(array_keys(Zend_Locale::getLocaleList())); $localeMultiOptions = array(); $languages = Zend_Locale::getTranslationList('language', $locale); $territories = Zend_Locale::getTranslationList('territory', $locale); foreach ($localeMultiKeys as $key) { if (!empty($languages[$key])) { $localeMultiOptions[$key] = $languages[$key]; } else { $locale = new Zend_Locale($key); $region = $locale->getRegion(); $language = $locale->getLanguage(); if (!empty($languages[$language]) && !empty($territories[$region])) { $localeMultiOptions[$key] = $languages[$language] . ' (' . $territories[$region] . ')'; } } } $localeMultiOptions = array_merge(array('auto' => '[Automatic]'), $localeMultiOptions); $this->addElement('Select', 'locale', array('label' => 'Locale', 'description' => 'Dates, times, and other settings will be displayed using this locale setting.', 'multiOptions' => $localeMultiOptions)); // Init submit $this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true)); // Create display group for buttons #$this->addDisplayGroup($emailAlerts, 'checkboxes'); // Set default action $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array('module' => 'user', 'controller' => 'settings', 'action' => 'general'), 'default')); }
protected function getLocales() { Loader::library('3rdparty/Zend/Locale'); $languages = Localization::getAvailableInterfaceLanguages(); if (count($languages) > 0) { array_unshift($languages, 'en_US'); } $locales = array(); foreach($languages as $lang) { $loc = new Zend_Locale($lang); $locales[$lang] = Zend_Locale::getTranslation($loc->getLanguage(), 'language', $lang); } return $locales; }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); // Uebersetzung vorhanden? if (!Registry::isRegistered('Zend_Translate')) { // Locale erweitern; Lade Uebersetzungen und speichere Translate Objekt in der Registry $lang = 'de'; $locale = new \Zend_Locale(); $locale->setLocale($lang); $langFile = APPLICATION_PATH . '/translations/' . $lang . '.php'; Registry::set('Zend_Translate', new \Zend_Translate('array', $langFile, $locale->getLanguage())); } }