Exemple #1
0
 /**
  * Validate the given value. Looks for the language translation list
  * in the registry (key 'Available_Languages'). If this key is not registered
  * the language list is obtained through a call to getLanguageTranslationList()
  * of Zend_Locale.
  *
  * @param string $value An enum string.
  * @return boolean True if the given enum string is known.
  */
 public function isValid($value)
 {
     if (false === is_array($value)) {
         $value = array($value);
     }
     $registry = Zend_Registry::getInstance();
     if ($registry->isRegistered('Available_Languages')) {
         $translationList = $registry->get('Available_Languages');
     } else {
         $locale = new Zend_Locale();
         $translationList = $locale->getLanguageTranslationList();
     }
     foreach ($value as $val) {
         $this->_setValue($val);
         if (is_string($val) === false) {
             $this->_error(self::MSG_LANGUAGE);
             return false;
         }
         if (array_key_exists($val, $translationList) === false) {
             $this->_error(self::MSG_LANGUAGE);
             return false;
         }
     }
     return true;
 }
Exemple #2
0
 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));
 }
    public function testDefaultLocale()
    {
        $lang = new Zend_Translate(Zend_Translate::AN_ARRAY, array());

        $defaultLocale = new Zend_Locale();
        $this->assertEquals($lang->getLocale(), $defaultLocale->toString());
    }
Exemple #4
0
 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;
 }
Exemple #5
0
 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");
 }
Exemple #7
0
 public function getFromList(&$list)
 {
     $current_locale = I18n::getInstance()->getCurrentLanguage();
     $country = BizSystem::clientProxy()->getFormInputs("fld_region");
     $country = strtoupper($country);
     if (!$country) {
         $locale = explode('_', $current_locale);
         $country = strtoupper($locale[0]);
     }
     require_once 'Zend/Locale.php';
     $locale = new Zend_Locale($current_locale);
     $code2name = $locale->getTranslationList('territorytolanguage', $locale);
     $list = array();
     $i = 0;
     foreach ($code2name as $key => $value) {
         if (preg_match('/' . $country . '/', $value) || strtoupper($key) == $country) {
             $lang_list = explode(" ", $value);
             foreach ($lang_list as $lang) {
                 $list[$i]['txt'] = strtolower($key) . "_" . strtoupper($lang);
                 $list[$i]['val'] = strtolower($key) . "_" . strtoupper($lang);
                 $i++;
             }
         }
     }
     return $list;
 }
 /**
  * @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');
     }
 }
Exemple #9
0
 /**
  * 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()
 {
     $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);
     }
 }
Exemple #11
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     // Get our translate object from registry.
     $translate = Zend_Registry::get('Zend_Translate');
     $currLocale = $translate->getLocale();
     // Create Session block and save the locale
     $session = new Zend_Session_Namespace('session');
     $lang = $request->getParam('language', '');
     // Register all your "approved" locales below.
     switch ($lang) {
         case "nl":
             $langLocale = 'nl_NL';
             break;
         case "en":
             $langLocale = 'en_US';
             break;
         default:
             /**
              * Get a previously set locale from session or set
              * the current application wide locale (set in
              * Bootstrap) if not.
              */
             $langLocale = isset($session->lang) ? $session->lang : $currLocale;
     }
     $newLocale = new Zend_Locale();
     $newLocale->setLocale($langLocale);
     Zend_Registry::set('Zend_Locale', $newLocale);
     $translate->setLocale($langLocale);
     $session->lang = $langLocale;
     // Save the modified translate back to registry
     Zend_Registry::set('Zend_Translate', $translate);
 }
Exemple #12
0
 /**
  * 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;
 }
Exemple #13
0
 /**
  * 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();
 }
 public function testBadLang()
 {
     $locale = new Zend_Locale();
     $locale->setLocale('qwerty');
     Zend_Registry::set('Zend_Locale', $locale);
     $this->setUp();
     $this->dispatch('/');
     $this->assertHeader('Content-Language', 'en');
 }
Exemple #15
0
 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;
         }
     }
 }
Exemple #16
0
 /**
  * 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();
 }
Exemple #17
0
 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);
 }
Exemple #18
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $lang = $request->getParam('lang', '');
     if ($lang !== 'id' && $lang !== 'en') {
         $request->setParam('lang', 'id');
     }
     $zl = new Zend_Locale();
     $zl->setLocale($lang);
     Zend_Registry::set('Zend_Locale', $zl);
 }
 /**
  * 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;
 }
Exemple #20
0
 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();
 }
Exemple #21
0
 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();
 }
Exemple #22
0
 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);
 }
 /**
  * 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;
 }
Exemple #24
0
 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'));
 }
Exemple #25
0
 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()));
     }
 }
Exemple #26
0
	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;
	}
 /**
  * Return the default language to use
  *
  * @return string
  */
 protected function _getDefaultLanguage()
 {
     $config = $this->getOptions();
     $languageList = array_keys($config['languages']);
     $defaultLanguage = '';
     if (array_key_exists('language', $_COOKIE)) {
         $defaultLanguage = $_COOKIE['language'];
     } else {
         $zl = new Zend_Locale();
         $defaultLanguage = $zl->getLanguage();
     }
     $defaultLanguage = in_array($defaultLanguage, $languageList) ? $defaultLanguage : 'en';
     return $defaultLanguage;
 }
 /**
  * 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 Field($properties = array())
 {
     $source = $this->getSource();
     if (!$this->value || !isset($source[$this->value])) {
         if ($this->config()->get('default_to_locale') && $this->locale()) {
             $locale = new Zend_Locale();
             $locale->setLocale($this->locale());
             $this->value = $locale->getRegion();
         }
     }
     if (!$this->value || !isset($source[$this->value])) {
         $this->value = $this->config()->get('default_country');
     }
     return parent::Field();
 }