示例#1
0
 /**
  * gets the full name of the currency from the LDML files
  * 
  * @return Zend_Currency
  * @throws Zend_Currency_Exception
  */
 protected function _updateFullName()
 {
     //getting the full name of the currency
     $names = Zend_Locale_Data::getContent('', 'currencynames', $this->_currencyLocale->getRegion());
     $this->_fullName = $names[$this->_shortName];
     return $this;
 }
示例#2
0
文件: Locale.php 项目: robeendey/ce
 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));
 }
示例#3
0
文件: Create.php 项目: robeendey/ce
 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')));
 }
示例#4
0
 /**
  * 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);
 }
示例#5
0
文件: I18n.php 项目: que273/siremis
 /**
  * Get best region from browser
  * @return <type>
  */
 public function getBestRegionFromBrowser()
 {
     $region = $this->_zLocale->getRegion();
     if ($region === FALSE) {
         return null;
     }
     return $region;
 }
示例#6
0
 public function on_start()
 {
     $this->error = Loader::helper('validation/error');
     if (USER_REGISTRATION_WITH_EMAIL_ADDRESS) {
         $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();
         Zend_Locale_Data::setCache(Cache::getLibrary());
         foreach ($languages as $lang) {
             $loc = new Zend_Locale($lang);
             $locales[$lang] = Zend_Locale::getTranslation($loc->getLanguage(), 'language', $lang);
             $locRegion = $loc->getRegion();
             if ($locRegion !== false) {
                 $locRegionName = $loc->getTranslation($loc->getRegion(), 'country', $lang);
                 if ($locRegionName !== false) {
                     $locales[$lang] .= ' (' . $locRegionName . ')';
                 }
             }
         }
         asort($locales);
         $locales = array_merge(array('' => t('** Default')), $locales);
     }
     $this->locales = $locales;
     $this->set('locales', $locales);
     $this->openIDReturnTo = BASE_URL . View::url("/login", "complete_openid");
 }
示例#7
0
文件: General.php 项目: robeendey/ce
 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'));
 }
示例#8
0
 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();
 }
示例#9
0
 public function init()
 {
     // Set form attributes
     $this->setTitle('Mail Templates')->setDescription('CORE_FORM_ADMIN_SETTINGS_EMAIL_DESCRIPTION');
     // Element: language
     $this->addElement('Select', 'language', array('label' => 'Language Pack', 'description' => 'Your community has more than one language pack installed. Please select the language pack you want to edit right now.', 'onchange' => 'javascript:setEmailLanguage(this.value);'));
     // Languages
     $localeObject = Zend_Registry::get('Locale');
     $translate = Zend_Registry::get('Zend_Translate');
     $languageList = $translate->getList();
     $languages = Zend_Locale::getTranslationList('language', $localeObject);
     $territories = Zend_Locale::getTranslationList('territory', $localeObject);
     $localeMultiOptions = array();
     foreach ($languageList 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 . ']';
         }
     }
     $defaultLanguage = Engine_Api::_()->getApi('settings', 'core')->getSetting('core.locale.locale', 'en');
     if (isset($localeMultiOptions[$defaultLanguage])) {
         $localeMultiOptions = array_merge(array($defaultLanguage => $localeMultiOptions[$defaultLanguage]), $localeMultiOptions);
     }
     $this->language->setMultiOptions($localeMultiOptions);
     // Element: template_id
     $this->addElement('Select', 'template', array('label' => 'Choose Message', 'onchange' => 'javascript:fetchEmailTemplate(this.value);', 'ignore' => true));
     $this->template->getDecorator("Description")->setOption("placement", "append");
     foreach (Engine_Api::_()->getDbtable('MailTemplates', 'core')->fetchAll() as $mailTemplate) {
         $title = $translate->_(strtoupper("_email_" . $mailTemplate->type . "_title"));
         $this->template->addMultiOption($mailTemplate->mailtemplate_id, $title);
     }
     // Element: subject
     $this->addElement('Text', 'subject', array('label' => 'Subject', 'style' => 'min-width:400px;'));
     // Element: body
     $this->addElement('Textarea', 'body', array('label' => 'Message Body'));
     // Element: submit
     $this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true));
 }
示例#10
0
 public function changelanguageAction()
 {
     $this->_helper->viewRenderer->setNoRender(true);
     //        die("language");
     $request = $this->getRequest();
     if ($this->getRequest()->isPost()) {
         $locale = new Zend_Locale($request->getPost('language'));
         $default = new Zend_Session_Namespace('default');
         $default->language = $locale->getLanguage();
         $default->locale = $locale->getRegion();
         $this->_redirect($request->getPost('refer'));
     } else {
         return;
     }
     return;
 }
 public function Field($properties = array())
 {
     $source = $this->getSource();
     // Default value to best availabel locale
     $value = $this->Value();
     if ($this->config()->default_to_locale && (!$value || !isset($source[$value])) && $this->locale()) {
         $locale = new Zend_Locale();
         $locale->setLocale($this->locale());
         $value = $locale->getRegion();
         $this->setValue($value);
     }
     // Default to default country otherwise
     if (!$value || !isset($source[$value])) {
         $this->setValue($this->config()->default_country);
     }
     return parent::Field($properties);
 }
示例#12
0
 protected function _initLocale()
 {
     $locale = new Zend_Locale();
     $config = $this->getOptions();
     $defaultLocale = $config['lang_local'];
     try {
         $locale = new Zend_Locale('auto');
     } catch (Zend_Locale_Exception $e) {
         $locale = new Zend_Locale($defaultLocale);
     }
     if (!isset($_SESSION['default']['locale'])) {
         $_SESSION['default']['locale'] = $locale->getRegion();
     }
     if (!isset($_SESSION['default']['language'])) {
         $_SESSION['default']['language'] = $locale->getLanguage();
     }
     Zend_Registry::set('Zend_Locale', $locale);
 }
示例#13
0
 /**
  * Sets the locale to use
  *
  * @param string|Zend_Locale $locale
  * @throws Zend_Validate_Exception On unrecognised region
  * @throws Zend_Validate_Exception On not detected format
  * @return Zend_Validate_PostCode  Provides fluid interface
  */
 public function setLocale($locale = null)
 {
     #require_once 'Zend/Locale.php';
     $this->_locale = Zend_Locale::findLocale($locale);
     $locale = new Zend_Locale($this->_locale);
     $region = $locale->getRegion();
     if (empty($region)) {
         #require_once 'Zend/Validate/Exception.php';
         throw new Zend_Validate_Exception("Unable to detect a region for the locale '{$locale}'");
     }
     $format = Zend_Locale::getTranslation($locale->getRegion(), 'postaltoterritory', $this->_locale);
     if (empty($format)) {
         #require_once 'Zend/Validate/Exception.php';
         throw new Zend_Validate_Exception("Unable to detect a postcode format for the region '{$locale->getRegion()}'");
     }
     $this->setFormat($format);
     return $this;
 }
示例#14
0
 /**
  * Returns the topics table as a presentation model (array of arrays containing
  * information about each topic, suitable for use by a view) by mirroring
  * the domain model into a presentation model.  The presentation model can be modified
  * to support the needs of a view, without mangling the raw, real underlying table data.
  * STAGE 4: Apply business logic to create a presentation model for the view.
  * @return array of ArrayObjects (containing topic info) indexed by topic id
  */
 public static function getPresentationModel()
 {
     if (self::$_presentationModel === null) {
         foreach (self::getDomainModel() as $row) {
             $row = new ArrayObject($row->toArray(), ArrayObject::ARRAY_AS_PROPS);
             $row->user = ZFDemoModel_Users::getById($row->user_id);
             self::$_presentationModel[$row->topic_id] = $row;
             /////////////////////////////
             // ==> SECTION: l10n <==
             // create a Locale object for the owner of this post (not the user of this request)
             $postLocale = new Zend_Locale($row->user->locale);
             $row->country = ZFModule_Forum::getCountry($postLocale->getRegion());
             $userLocale = ZFModule_Forum::getUserLocale();
             // locale of the user of this request
             $userLocale = Zend_Registry::get('userLocale');
             $offset = ZFModule_Forum::getTimeOffset();
             if ($row->modification_time != $row->creation_time) {
                 $row->modification_time = new Zend_Date($row->modification_time, $userLocale);
                 $row->modification_time->addTimestamp($offset);
                 // express date/time in user's local timezone
             } else {
                 $row->modification_time = '';
             }
             $row->creation_time = new Zend_Date($row->creation_time, $userLocale);
             $row->creation_time->addTimestamp($offset);
             // express date/time in user's local timezone
         }
     }
     return self::$_presentationModel;
 }
示例#15
0
 public static function getCountryLanguages()
 {
     if (!self::$countryLanguages) {
         $locales = Zend_Locale::getLocaleList();
         $enLocale = new Zend_Locale('en');
         $countries = array();
         foreach ($locales as $k => $v) {
             $tmpLocale = new Zend_Locale($k);
             $region = $tmpLocale->getRegion();
             try {
                 $countryName = Zend_Locale::getTranslation($region, 'Territory', self::getLocale());
                 if (!trim($countryName)) {
                     throw new Zmz_Culture_Exception('No translation for current locale');
                 }
             } catch (Exception $e) {
                 $countryName = Zend_Locale::getTranslation($region, 'Territory', $enLocale);
             }
             if (!trim($countryName)) {
                 continue;
             }
             try {
                 $languageTranslation = Zend_Locale::getTranslation($tmpLocale->getLanguage(), 'language', self::getLocale());
                 if (!trim($languageTranslation)) {
                     throw new Zmz_Culture_Exception('No translation for current locale');
                 }
             } catch (Exception $e) {
                 $languageTranslation = Zend_Locale::getTranslation($tmpLocale->getLanguage(), 'language', $enLocale);
             }
             if (!trim($languageTranslation)) {
                 continue;
             }
             if (!isset($countries[$region])) {
                 $countries[$region] = array('name' => $countryName, 'locales' => array());
             }
             $countries[$region]['locales'][$k] = $languageTranslation;
         }
         self::$countryLanguages = $countries;
     }
     return self::$countryLanguages;
 }
示例#16
0
文件: Tool.php 项目: krugerke/pimcore
 /**
  * @return array|mixed
  * @throws \Zend_Locale_Exception
  */
 public static function getSupportedLocales()
 {
     // List of locales that are no longer part of CLDR
     // this was also changed in the Zend Framework, but here we need to provide an appropriate alternative
     // since this information isn't public in \Zend_Locale :-(
     $aliases = ['az_AZ' => true, 'bs_BA' => true, 'ha_GH' => true, 'ha_NE' => true, 'ha_NG' => true, 'kk_KZ' => true, 'ks_IN' => true, 'mn_MN' => true, 'ms_BN' => true, 'ms_MY' => true, 'ms_SG' => true, 'pa_IN' => true, 'pa_PK' => true, 'shi_MA' => true, 'sr_BA' => true, 'sr_ME' => true, 'sr_RS' => true, 'sr_XK' => true, 'tg_TJ' => true, 'tzm_MA' => true, 'uz_AF' => true, 'uz_UZ' => true, 'vai_LR' => true, 'zh_CN' => true, 'zh_HK' => true, 'zh_MO' => true, 'zh_SG' => true, 'zh_TW' => true];
     $locale = \Zend_Locale::findLocale();
     $cacheKey = "system_supported_locales_" . strtolower((string) $locale);
     if (!($languageOptions = Cache::load($cacheKey))) {
         // we use the locale here, because \Zend_Translate only supports locales not "languages"
         $languages = \Zend_Locale::getLocaleList();
         $languages = array_merge($languages, $aliases);
         $languageOptions = array();
         foreach ($languages as $code => $active) {
             if ($active) {
                 $translation = \Zend_Locale::getTranslation($code, "language");
                 if (!$translation) {
                     $tmpLocale = new \Zend_Locale($code);
                     $lt = \Zend_Locale::getTranslation($tmpLocale->getLanguage(), "language");
                     $tt = \Zend_Locale::getTranslation($tmpLocale->getRegion(), "territory");
                     if ($lt && $tt) {
                         $translation = $lt . " (" . $tt . ")";
                     }
                 }
                 if (!$translation) {
                     $translation = $code;
                 }
                 $languageOptions[$code] = $translation;
             }
         }
         asort($languageOptions);
         Cache::save($languageOptions, $cacheKey, ["system"]);
     }
     return $languageOptions;
 }
示例#17
0
 /**
  * Get the description of a locale consisting of language and region description
  * e.g. "French (France)"
  * @param string $locale Locale that should be described
  * @param string $displayLocale Language of the description
  * @return string Description of a language
  */
 public static function getLanguageDescription($locale, $displayLocale = null)
 {
     $localeList = Zend_Locale::getLocaleList();
     if (!isset($localeList[$locale])) {
         return $locale;
     }
     if ($displayLocale !== NULL && !isset($localeList[$displayLocale])) {
         $displayLocale = NULL;
     }
     $cacheLibrary = Cache::getLibrary();
     if (is_object($cacheLibrary)) {
         Zend_Locale_Data::setCache($cacheLibrary);
     }
     $displayLocale = $displayLocale ? $displayLocale : $locale;
     $zendLocale = new Zend_Locale($locale);
     $languageName = Zend_Locale::getTranslation($zendLocale->getLanguage(), 'language', $displayLocale);
     $description = $languageName;
     $region = $zendLocale->getRegion();
     if ($region !== false) {
         $regionName = Zend_Locale::getTranslation($region, 'country', $displayLocale);
         if ($regionName !== false) {
             $localeData = Zend_Locale_Data::getList($displayLocale, 'layout');
             if ($localeData['characters'] == "right-to-left") {
                 $description = '(' . $languageName . ' (' . $regionName;
             } else {
                 $description = $languageName . ' (' . $regionName . ")";
             }
         }
     }
     return $description;
 }
示例#18
0
 /**
  * Returns the posts of a topic as a presentation model (array of arrays containing
  * information about each post, suitable for use by a view) by mirroring the domain model
  * into a presentation model.  The presentation model can be modified to support
  * the needs of a view, without mangling the raw, real underlying table data.
  * STAGE 4: Apply business logic to create a presentation model for the view.
  * @return array of ArrayObject (post info)
  */
 public static function getPostsByTopicId($topicId)
 {
     if (!isset(self::$_presentationModel[$topicId])) {
         $posts = array();
         foreach (self::getDomainModel($topicId) as $row) {
             $row = new ArrayObject($row->toArray(), ArrayObject::ARRAY_AS_PROPS);
             $row->user = ZFDemoModel_Users::getById($row->user_id);
             $posts[] = $row;
             /////////////////////////////
             // ==> SECTION: l10n <==
             // create a Locale object for the owner of this post (not the user of this request)
             $postLocale = new Zend_Locale($row->user->locale);
             $row->country = ZFModule_Forum::getCountry($postLocale->getRegion());
             $userLocale = ZFModule_Forum::getUserLocale();
             // locale of the user of this request
             $offset = ZFModule_Forum::getTimeOffset();
             if ($row->modification_time != $row->creation_time) {
                 $row->modification_time = new Zend_Date($row->modification_time, $userLocale);
                 $row->modification_time->addTimestamp($offset);
                 // express date/time in user's local timezone
             } else {
                 $row->modification_time = '';
             }
             $row->creation_time = new Zend_Date($row->creation_time, $userLocale);
             $row->creation_time->addTimestamp($offset);
             // express date/time in user's local timezone
         }
         // cache result only for duration of this request
         self::$_presentationModel[$topicId] = $posts;
     }
     return self::$_presentationModel[$topicId];
 }
/**
 * generate statistics
 *
 * @param  bool $_verbose
 * @return void
 */
function statistics($_verbose)
{
    global $tine20path;
    $statsFile = "{$tine20path}/langstatistics.json";
    $locale = new Zend_Locale('en');
    $langStats = array();
    $poFilesStats = array();
    foreach (Tinebase_Translation::getTranslationDirs() as $appName => $translationPath) {
        if (!checkAppName($appName, $_verbose)) {
            continue;
        }
        if ($_verbose) {
            echo "Entering {$appName} \n";
        }
        $appStats[$appName] = array();
        foreach (scandir($translationPath) as $poFile) {
            if (substr($poFile, -3) == '.po') {
                if ($_verbose) {
                    echo "Processing {$appName}/{$poFile} \n";
                }
                $langCode = substr($poFile, 0, -3);
                $langLocale = new Zend_Locale($langCode);
                $statsOutput = `msgfmt --statistics {$translationPath}/{$poFile} 2>&1`;
                $statsParts = explode(',', $statsOutput);
                $statsParts = preg_replace('/^\\s*(\\d+).*/i', '$1', $statsParts);
                $translated = $fuzzy = $untranslated = $total = 0;
                switch (count($statsParts)) {
                    case 1:
                        $translated = $statsParts[0];
                        break;
                    case 2:
                        $translated = $statsParts[0];
                        $untranslated = $statsParts[1];
                        break;
                    case 3:
                        $translated = $statsParts[0];
                        $fuzzy = $statsParts[1];
                        $untranslated = $statsParts[2];
                        break;
                    default:
                        echo "Unexpected statistic return \n";
                        exit;
                }
                $total = array_sum($statsParts);
                $poFileStats = array('locale' => $langCode, 'language' => $locale->getTranslation($langLocale->getLanguage(), 'language'), 'region' => $locale->getTranslation($langLocale->getRegion(), 'country'), 'appname' => $appName, 'translated' => (int) $translated, 'fuzzy' => (int) $fuzzy, 'untranslated' => (int) $untranslated, 'total' => array_sum($statsParts));
                $poFilesStats[] = $poFileStats;
                // sum up lang statistics
                $langStats[$langCode] = isset($langStats[$langCode]) || array_key_exists($langCode, $langStats) ? $langStats[$langCode] : array('locale' => '', 'language' => '', 'region' => $locale->getTranslation($langLocale->getRegion(), 'country'), 'translated' => 0, 'fuzzy' => 0, 'untranslated' => 0, 'total' => 0);
                $langStats[$langCode]['locale'] = $langCode;
                $langStats[$langCode]['language'] = $locale->getTranslation($langLocale->getLanguage(), 'language');
                $langStats[$langCode]['region'] = $locale->getTranslation($langLocale->getRegion(), 'country');
                $langStats[$langCode]['appname'] = 'all';
                $langStats[$langCode]['translated'] += $poFileStats['translated'];
                $langStats[$langCode]['fuzzy'] += $poFileStats['fuzzy'];
                $langStats[$langCode]['untranslated'] += $poFileStats['untranslated'];
                $langStats[$langCode]['total'] += $poFileStats['total'];
            }
        }
    }
    // clean up unwanted messages.mo
    `rm messages.mo`;
    $results = array('version' => Tinebase_Helper::getDevelopmentRevision(), 'langStats' => array_values($langStats), 'poFilesStats' => $poFilesStats);
    file_put_contents($statsFile, Zend_Json::encode($results));
}
 /**
  * Run the Country code through a converter to get the proper Country Name
  */
 function FullCountry()
 {
     $locale = new Zend_Locale();
     $locale->setLocale($this->owner->Country);
     return $locale->getRegion();
 }
示例#21
0
文件: Data.php 项目: grlf/eyedock
 /**
  * Read the LDML file, get a single path defined value
  *
  * @param  string $locale
  * @param  string $path
  * @param  string $value
  * @return string
  * @access public
  */
 public static function getContent($locale, $path, $value = false)
 {
     $locale = self::_checkLocale($locale);
     if (!isset(self::$_cache) && !self::$_cacheDisabled) {
         //--//require_once 'Zend/Cache.php';
         self::$_cache = Zend_Cache::factory('Core', 'File', array('automatic_serialization' => true), array());
     }
     $val = $value;
     if (is_array($value)) {
         $val = implode('_', $value);
     }
     $val = urlencode($val);
     $id = strtr('Zend_LocaleC_' . $locale . '_' . $path . '_' . $val, array('-' => '_', '%' => '_', '+' => '_'));
     if (!self::$_cacheDisabled && ($result = self::$_cache->load($id))) {
         return unserialize($result);
     }
     switch (strtolower($path)) {
         case 'language':
             $temp = self::_getFile($locale, '/ldml/localeDisplayNames/languages/language[@type=\'' . $value . '\']', 'type');
             break;
         case 'script':
             $temp = self::_getFile($locale, '/ldml/localeDisplayNames/scripts/script[@type=\'' . $value . '\']', 'type');
             break;
         case 'country':
         case 'territory':
             $temp = self::_getFile($locale, '/ldml/localeDisplayNames/territories/territory[@type=\'' . $value . '\']', 'type');
             break;
         case 'variant':
             $temp = self::_getFile($locale, '/ldml/localeDisplayNames/variants/variant[@type=\'' . $value . '\']', 'type');
             break;
         case 'key':
             $temp = self::_getFile($locale, '/ldml/localeDisplayNames/keys/key[@type=\'' . $value . '\']', 'type');
             break;
         case 'defaultcalendar':
             $givenLocale = new Zend_Locale($locale);
             $territory = $givenLocale->getRegion();
             unset($givenLocale);
             $temp = self::_getFile('supplementalData', '/supplementalData/calendarPreferenceData/calendarPreference[contains(@territories,\'' . $territory . '\')]', 'ordering', 'ordering');
             if (isset($temp['ordering'])) {
                 list($temp) = explode(' ', $temp['ordering']);
             } else {
                 $temp = 'gregorian';
             }
             break;
         case 'monthcontext':
             /* default context is always 'format'
                if (empty ($value)) {
                    $value = "gregorian";
                }
                $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/default', 'choice', 'context');
                */
             $temp = 'format';
             break;
         case 'defaultmonth':
             /* default width is always 'wide'
                if (empty ($value)) {
                    $value = "gregorian";
                }
                $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/months/monthContext[@type=\'format\']/default', 'choice', 'default');
                */
             $temp = 'wide';
             break;
         case 'month':
             if (!is_array($value)) {
                 $temp = $value;
                 $value = array("gregorian", "format", "wide", $temp);
             }
             $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/months/monthContext[@type=\'' . $value[1] . '\']/monthWidth[@type=\'' . $value[2] . '\']/month[@type=\'' . $value[3] . '\']', 'type');
             break;
         case 'daycontext':
             /* default context is always 'format'
                if (empty($value)) {
                    $value = "gregorian";
                }
                $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/default', 'choice', 'context');
                */
             $temp = 'format';
             break;
         case 'defaultday':
             /* default width is always 'wide'
                if (empty($value)) {
                    $value = "gregorian";
                }
                $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/days/dayContext[@type=\'format\']/default', 'choice', 'default');
                */
             $temp = 'wide';
             break;
         case 'day':
             if (!is_array($value)) {
                 $temp = $value;
                 $value = array("gregorian", "format", "wide", $temp);
             }
             $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/days/dayContext[@type=\'' . $value[1] . '\']/dayWidth[@type=\'' . $value[2] . '\']/day[@type=\'' . $value[3] . '\']', 'type');
             break;
         case 'quarter':
             if (!is_array($value)) {
                 $temp = $value;
                 $value = array("gregorian", "format", "wide", $temp);
             }
             $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/quarters/quarterContext[@type=\'' . $value[1] . '\']/quarterWidth[@type=\'' . $value[2] . '\']/quarter[@type=\'' . $value[3] . '\']', 'type');
             break;
         case 'am':
             if (empty($value)) {
                 $value = array("gregorian", "format", "wide");
             }
             if (!is_array($value)) {
                 $temp = $value;
                 $value = array($temp, "format", "wide");
             }
             $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dayPeriods/dayPeriodContext[@type=\'' . $value[1] . '\']/dayPeriodWidth[@type=\'' . $value[2] . '\']/dayPeriod[@type=\'am\']', '', 'dayPeriod');
             break;
         case 'pm':
             if (empty($value)) {
                 $value = array("gregorian", "format", "wide");
             }
             if (!is_array($value)) {
                 $temp = $value;
                 $value = array($temp, "format", "wide");
             }
             $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dayPeriods/dayPeriodContext[@type=\'' . $value[1] . '\']/dayPeriodWidth[@type=\'' . $value[2] . '\']/dayPeriod[@type=\'pm\']', '', 'dayPeriod');
             break;
         case 'era':
             if (!is_array($value)) {
                 $temp = $value;
                 $value = array("gregorian", "Abbr", $temp);
             }
             $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/eras/era' . $value[1] . '/era[@type=\'' . $value[2] . '\']', 'type');
             break;
         case 'defaultdate':
             /* default choice is deprecated in CDLR - should be always medium here
                if (empty($value)) {
                    $value = "gregorian";
                }
                $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/dateFormats/default', 'choice', 'default');
                */
             $temp = 'medium';
             break;
         case 'date':
             if (empty($value)) {
                 $value = array("gregorian", "medium");
             }
             if (!is_array($value)) {
                 $temp = $value;
                 $value = array("gregorian", $temp);
             }
             $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateFormats/dateFormatLength[@type=\'' . $value[1] . '\']/dateFormat/pattern', '', 'pattern');
             break;
         case 'defaulttime':
             /* default choice is deprecated in CDLR - should be always medium here
                if (empty($value)) {
                    $value = "gregorian";
                }
                $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value . '\']/timeFormats/default', 'choice', 'default');
                */
             $temp = 'medium';
             break;
         case 'time':
             if (empty($value)) {
                 $value = array("gregorian", "medium");
             }
             if (!is_array($value)) {
                 $temp = $value;
                 $value = array("gregorian", $temp);
             }
             $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/timeFormats/timeFormatLength[@type=\'' . $value[1] . '\']/timeFormat/pattern', '', 'pattern');
             break;
         case 'datetime':
             if (empty($value)) {
                 $value = array("gregorian", "medium");
             }
             if (!is_array($value)) {
                 $temp = $value;
                 $value = array("gregorian", $temp);
             }
             $date = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateFormats/dateFormatLength[@type=\'' . $value[1] . '\']/dateFormat/pattern', '', 'pattern');
             $time = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/timeFormats/timeFormatLength[@type=\'' . $value[1] . '\']/timeFormat/pattern', '', 'pattern');
             $datetime = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateTimeFormats/dateTimeFormatLength[@type=\'' . $value[1] . '\']/dateTimeFormat/pattern', '', 'pattern');
             $temp = str_replace(array('{0}', '{1}'), array(current($time), current($date)), current($datetime));
             break;
         case 'dateitem':
             if (empty($value)) {
                 $value = array("gregorian", "yyMMdd");
             }
             if (!is_array($value)) {
                 $temp = $value;
                 $value = array("gregorian", $temp);
             }
             $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateTimeFormats/availableFormats/dateFormatItem[@id=\'' . $value[1] . '\']', '');
             break;
         case 'dateinterval':
             if (empty($value)) {
                 $value = array("gregorian", "yMd", "y");
             }
             if (!is_array($value)) {
                 $temp = $value;
                 $value = array("gregorian", $temp, $temp[0]);
             }
             $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/dateTimeFormats/intervalFormats/intervalFormatItem[@id=\'' . $value[1] . '\']/greatestDifference[@id=\'' . $value[2] . '\']', '');
             break;
         case 'field':
             if (!is_array($value)) {
                 $temp = $value;
                 $value = array("gregorian", $temp);
             }
             $temp = self::_getFile($locale, '/ldml/dates/fields/field[@type=\'' . $value[1] . '\']/displayName', '', $value[1]);
             break;
         case 'relative':
             if (!is_array($value)) {
                 $temp = $value;
                 $value = array("gregorian", $temp);
             }
             $temp = self::_getFile($locale, '/ldml/dates/fields/field[@type=\'day\']/relative[@type=\'' . $value[1] . '\']', '', $value[1]);
             // $temp = self::_getFile($locale, '/ldml/dates/calendars/calendar[@type=\'' . $value[0] . '\']/fields/field/relative[@type=\'' . $value[1] . '\']', '', $value[1]);
             break;
         case 'defaultnumberingsystem':
             $temp = self::_getFile($locale, '/ldml/numbers/defaultNumberingSystem', '', 'default');
             break;
         case 'decimalnumber':
             $temp = self::_getFile($locale, '/ldml/numbers/decimalFormats/decimalFormatLength/decimalFormat/pattern', '', 'default');
             break;
         case 'scientificnumber':
             $temp = self::_getFile($locale, '/ldml/numbers/scientificFormats/scientificFormatLength/scientificFormat/pattern', '', 'default');
             break;
         case 'percentnumber':
             $temp = self::_getFile($locale, '/ldml/numbers/percentFormats/percentFormatLength/percentFormat/pattern', '', 'default');
             break;
         case 'currencynumber':
             $temp = self::_getFile($locale, '/ldml/numbers/currencyFormats/currencyFormatLength/currencyFormat/pattern', '', 'default');
             break;
         case 'nametocurrency':
             $temp = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $value . '\']/displayName', '', $value);
             break;
         case 'currencytoname':
             $temp = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $value . '\']/displayName', '', $value);
             $_temp = self::_getFile($locale, '/ldml/numbers/currencies/currency', 'type');
             $temp = array();
             foreach ($_temp as $key => $keyvalue) {
                 $val = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $key . '\']/displayName', '', $key);
                 if (!isset($val[$key]) or $val[$key] != $value) {
                     continue;
                 }
                 if (!isset($temp[$val[$key]])) {
                     $temp[$val[$key]] = $key;
                 } else {
                     $temp[$val[$key]] .= " " . $key;
                 }
             }
             break;
         case 'currencysymbol':
             $temp = self::_getFile($locale, '/ldml/numbers/currencies/currency[@type=\'' . $value . '\']/symbol', '', $value);
             break;
         case 'question':
             $temp = self::_getFile($locale, '/ldml/posix/messages/' . $value . 'str', '', $value);
             break;
         case 'currencyfraction':
             if (empty($value)) {
                 $value = "DEFAULT";
             }
             $temp = self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info[@iso4217=\'' . $value . '\']', 'digits', 'digits');
             break;
         case 'currencyrounding':
             if (empty($value)) {
                 $value = "DEFAULT";
             }
             $temp = self::_getFile('supplementalData', '/supplementalData/currencyData/fractions/info[@iso4217=\'' . $value . '\']', 'rounding', 'rounding');
             break;
         case 'currencytoregion':
             $temp = self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $value . '\']/currency', 'iso4217', $value);
             break;
         case 'regiontocurrency':
             $_temp = self::_getFile('supplementalData', '/supplementalData/currencyData/region', 'iso3166');
             $temp = array();
             foreach ($_temp as $key => $keyvalue) {
                 $val = self::_getFile('supplementalData', '/supplementalData/currencyData/region[@iso3166=\'' . $key . '\']/currency', 'iso4217', $key);
                 if (!isset($val[$key]) or $val[$key] != $value) {
                     continue;
                 }
                 if (!isset($temp[$val[$key]])) {
                     $temp[$val[$key]] = $key;
                 } else {
                     $temp[$val[$key]] .= " " . $key;
                 }
             }
             break;
         case 'regiontoterritory':
             $temp = self::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $value . '\']', 'contains', $value);
             break;
         case 'territorytoregion':
             $_temp2 = self::_getFile('supplementalData', '/supplementalData/territoryContainment/group', 'type');
             $_temp = array();
             foreach ($_temp2 as $key => $found) {
                 $_temp += self::_getFile('supplementalData', '/supplementalData/territoryContainment/group[@type=\'' . $key . '\']', 'contains', $key);
             }
             $temp = array();
             foreach ($_temp as $key => $found) {
                 $_temp3 = explode(" ", $found);
                 foreach ($_temp3 as $found3) {
                     if ($found3 !== $value) {
                         continue;
                     }
                     if (!isset($temp[$found3])) {
                         $temp[$found3] = (string) $key;
                     } else {
                         $temp[$found3] .= " " . $key;
                     }
                 }
             }
             break;
         case 'scripttolanguage':
             $temp = self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $value . '\']', 'scripts', $value);
             break;
         case 'languagetoscript':
             $_temp2 = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type');
             $_temp = array();
             foreach ($_temp2 as $key => $found) {
                 $_temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'scripts', $key);
             }
             $temp = array();
             foreach ($_temp as $key => $found) {
                 $_temp3 = explode(" ", $found);
                 foreach ($_temp3 as $found3) {
                     if ($found3 !== $value) {
                         continue;
                     }
                     if (!isset($temp[$found3])) {
                         $temp[$found3] = (string) $key;
                     } else {
                         $temp[$found3] .= " " . $key;
                     }
                 }
             }
             break;
         case 'territorytolanguage':
             $temp = self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $value . '\']', 'territories', $value);
             break;
         case 'languagetoterritory':
             $_temp2 = self::_getFile('supplementalData', '/supplementalData/languageData/language', 'type');
             $_temp = array();
             foreach ($_temp2 as $key => $found) {
                 $_temp += self::_getFile('supplementalData', '/supplementalData/languageData/language[@type=\'' . $key . '\']', 'territories', $key);
             }
             $temp = array();
             foreach ($_temp as $key => $found) {
                 $_temp3 = explode(" ", $found);
                 foreach ($_temp3 as $found3) {
                     if ($found3 !== $value) {
                         continue;
                     }
                     if (!isset($temp[$found3])) {
                         $temp[$found3] = (string) $key;
                     } else {
                         $temp[$found3] .= " " . $key;
                     }
                 }
             }
             break;
         case 'timezonetowindows':
             $temp = self::_getFile('windowsZones', '/supplementalData/windowsZones/mapTimezones/mapZone[@other=\'' . $value . '\']', 'type', $value);
             break;
         case 'windowstotimezone':
             $temp = self::_getFile('windowsZones', '/supplementalData/windowsZones/mapTimezones/mapZone[@type=\'' . $value . '\']', 'other', $value);
             break;
         case 'territorytotimezone':
             $temp = self::_getFile('metaZones', '/supplementalData/metaZones/mapTimezones/mapZone[@type=\'' . $value . '\']', 'territory', $value);
             break;
         case 'timezonetoterritory':
             $temp = self::_getFile('metaZones', '/supplementalData/metaZones/mapTimezones/mapZone[@territory=\'' . $value . '\']', 'type', $value);
             break;
         case 'citytotimezone':
             $temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $value . '\']/exemplarCity', '', $value);
             break;
         case 'timezonetocity':
             $_temp = self::_getFile($locale, '/ldml/dates/timeZoneNames/zone', 'type');
             $temp = array();
             foreach ($_temp as $key => $found) {
                 $temp += self::_getFile($locale, '/ldml/dates/timeZoneNames/zone[@type=\'' . $key . '\']/exemplarCity', '', $key);
                 if (!empty($temp[$key])) {
                     if ($temp[$key] == $value) {
                         $temp[$temp[$key]] = $key;
                     }
                 }
                 unset($temp[$key]);
             }
             break;
         case 'phonetoterritory':
             $temp = self::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory[@territory=\'' . $value . '\']/telephoneCountryCode', 'code', $value);
             break;
         case 'territorytophone':
             $_temp2 = self::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory', 'territory');
             $_temp = array();
             foreach ($_temp2 as $key => $found) {
                 $_temp += self::_getFile('telephoneCodeData', '/supplementalData/telephoneCodeData/codesByTerritory[@territory=\'' . $key . '\']/telephoneCountryCode', 'code', $key);
             }
             $temp = array();
             foreach ($_temp as $key => $found) {
                 $_temp3 = explode(" ", $found);
                 foreach ($_temp3 as $found3) {
                     if ($found3 !== $value) {
                         continue;
                     }
                     if (!isset($temp[$found3])) {
                         $temp[$found3] = (string) $key;
                     } else {
                         $temp[$found3] .= " " . $key;
                     }
                 }
             }
             break;
         case 'numerictoterritory':
             $temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@type=\'' . $value . '\']', 'numeric', $value);
             break;
         case 'territorytonumeric':
             $temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@numeric=\'' . $value . '\']', 'type', $value);
             break;
         case 'alpha3toterritory':
             $temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@type=\'' . $value . '\']', 'alpha3', $value);
             break;
         case 'territorytoalpha3':
             $temp = self::_getFile('supplementalData', '/supplementalData/codeMappings/territoryCodes[@alpha3=\'' . $value . '\']', 'type', $value);
             break;
         case 'postaltoterritory':
             $temp = self::_getFile('postalCodeData', '/supplementalData/postalCodeData/postCodeRegex[@territoryId=\'' . $value . '\']', 'territoryId');
             break;
         case 'numberingsystem':
             $temp = self::_getFile('numberingSystems', '/supplementalData/numberingSystems/numberingSystem[@id=\'' . strtolower($value) . '\']', 'digits', $value);
             break;
         case 'chartofallback':
             $_temp = self::_getFile('characters', '/supplementalData/characters/character-fallback/character', 'value');
             foreach ($_temp as $key => $keyvalue) {
                 $temp2 = self::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $key . '\']/substitute', '', $key);
                 if (current($temp2) == $value) {
                     $temp = $key;
                 }
             }
             break;
             $temp = self::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $value . '\']/substitute', '', $value);
             break;
         case 'fallbacktochar':
             $temp = self::_getFile('characters', '/supplementalData/characters/character-fallback/character[@value=\'' . $value . '\']/substitute', '');
             break;
         case 'localeupgrade':
             $temp = self::_getFile('likelySubtags', '/supplementalData/likelySubtags/likelySubtag[@from=\'' . $value . '\']', 'to', $value);
             break;
         case 'unit':
             $temp = self::_getFile($locale, '/ldml/units/unitLength/unit[@type=\'' . $value[0] . '\']/unitPattern[@count=\'' . $value[1] . '\']', '');
             break;
         default:
             //--//require_once 'Zend/Locale/Exception.php';
             throw new Zend_Locale_Exception("Unknown detail ({$path}) for parsing locale data.");
             break;
     }
     if (is_array($temp)) {
         $temp = current($temp);
     }
     if (isset(self::$_cache)) {
         if (self::$_cacheTags) {
             self::$_cache->save(serialize($temp), $id, array('Zend_Locale'));
         } else {
             self::$_cache->save(serialize($temp), $id);
         }
     }
     return $temp;
 }
示例#22
0
 public function load_icons()
 {
     if (!$this->post('msLanguage')) {
         return false;
     }
     $ch = Loader::helper('interface/flag', 'multilingual');
     Loader::library('3rdparty/Zend/Locale');
     // here's what we do. We load all locales, then we filter through all those that match the posted language code
     // and we return html for all regions in that language
     $locales = Zend_Locale::getLocaleList();
     $countries = array();
     $html = '';
     foreach ($locales as $locale => $none) {
         $zl = new Zend_Locale($locale);
         if ($zl->getLanguage() == $this->post('msLanguage') || $zl->toString() == $this->post('msLanguage')) {
             if ($zl->getRegion()) {
                 $countries[$zl->getRegion()] = Zend_Locale::getTranslation($zl->getRegion(), 'country', ACTIVE_LOCALE);
             }
         }
     }
     asort($countries);
     $i = 1;
     foreach ($countries as $region => $value) {
         $flag = $ch->getFlagIcon($region);
         if ($flag) {
             $checked = "";
             if ($this->post('selectedLanguageIcon') == $region) {
                 $checked = "checked=\"checked\"";
             } else {
                 if ($i == 1 && !$this->post('selectedLanguageIcon')) {
                     $checked = "checked=\"checked\"";
                 }
             }
             $html .= '<li><label><input type="radio" name="msIcon" ' . $checked . ' id="languageIcon' . $i . '" value="' . $region . '" onchange="ccm_multilingualUpdateLocale(\'' . $region . '\')" /><span class="image-wrapper">' . $flag . '' . $value . '</span></label></li>';
             $i++;
         }
     }
     if ($i == 1) {
         $html = "<li><label><span><strong>" . t('None') . "</strong></span></label></li>";
     }
     print $html;
     exit;
 }
 /**
  * Simple constructor that sets the country code and zip. If no
  * country is set, this class attempts to autodetect.
  * 
  * @param country_code 2 character country code
  * @param zipcode string of the zipo/postal code
  */
 public function __construct($zipcode, $country_code = null)
 {
     if ($country_code) {
         $this->country_code = $country_code;
     } else {
         $locale = new Zend_Locale();
         $locale->setLocale($this->locale());
         $this->country_code = $locale->getRegion();
     }
     if ($zipcode) {
         $this->zipcode = $zipcode;
     }
 }
 public function editAction()
 {
     $this->view->locale = $locale = $this->_getParam('locale');
     $this->view->page = $page = $this->_getParam('page');
     $translate = Zend_Registry::get('Zend_Translate');
     try {
         if (!$locale || !Zend_Locale::findLocale($locale)) {
             throw new Exception('missing locale ' . $locale);
         }
     } catch (Exception $e) {
         return $this->_helper->redirector->gotoRoute(array('action' => 'index', 'controller' => 'language'), 'admin_default', true);
     }
     // Process filter form
     $this->view->filterForm = $filterForm = new Core_Form_Admin_Language_Filter();
     $filterForm->isValid($this->_getAllParams());
     $filterValues = $filterForm->getValues();
     extract($filterValues);
     // search, show
     // Make query
     $filterValues = array_filter($filterValues);
     $this->view->values = $filterValues;
     $this->view->query = empty($filterValues) ? '' : '?' . http_build_query($filterValues);
     // Assign basic locale info
     $this->view->localeObject = $localeObject = new Zend_Locale($locale);
     $this->view->locale = $locale = $localeObject->toString();
     // Get locale translation info
     $localeLanguage = $localeObject->getLanguage();
     $localeRegion = $localeObject->getRegion();
     $this->view->localeLanguageTranslation = $localeLanguageTranslation = Zend_Locale::getTranslation($localeLanguage, 'language', Zend_Registry::get('Locale'));
     $this->view->localeRegionTranslation = $localeRegionTranslation = Zend_Locale::getTranslation($localeRegion, 'territory', Zend_Registry::get('Locale'));
     $translate = Zend_Registry::get('Zend_Translate');
     if ($localeLanguageTranslation && $localeRegionTranslation) {
         $this->view->localeTranslation = $localeLanguageTranslation . ' ' . sprintf($translate->translate('(%s)'), $localeRegionTranslation) . ' ' . sprintf($translate->translate('[%s]'), $locale);
     } else {
         if ($localeLanguageTranslation) {
             $this->view->localeTranslation = $localeLanguageTranslation . ' ' . sprintf($translate->translate('[%s]'), $locale);
         } else {
             $this->view->localeTranslation = sprintf($translate->translate('[%s]'), $locale);
         }
     }
     // Query plural system for max and sample space
     $sample = array();
     $max = 0;
     for ($i = 0; $i <= 1000; $i++) {
         $form = Zend_Translate_Plural::getPlural($i, $locale);
         $max = max($max, $form);
         if (@count($sample[$form]) < 3) {
             $sample[$form][] = $i;
         }
     }
     $this->view->pluralFormCount = $max + 1;
     $this->view->pluralFormSample = $sample;
     // Get initial and default values
     $baseMessages = $translate->getMessages('en');
     if ($translate->isAvailable($locale)) {
         $currentMessages = $translate->getMessages($locale);
     } else {
         $currentMessages = array();
         // @todo this should redirect or smth
     }
     // Get phrases that are not in the english pack?
     if (!empty($currentMessages) && $locale != 'en') {
         $missingBasePhrases = array_diff_key($currentMessages, $baseMessages);
         $missingBasePhrases = array_combine(array_keys($missingBasePhrases), array_keys($missingBasePhrases));
         $baseMessages = array_merge($baseMessages, $missingBasePhrases);
     }
     // Build the fancy array
     $resultantMessages = array();
     $missing = 0;
     $index = 0;
     foreach ($baseMessages as $key => $value) {
         // Build
         $composite = array('uid' => ++$index, 'key' => $key, 'original' => $value, 'plural' => (bool) is_array($value));
         // filters, plurals, and missing, oh my.
         if (isset($currentMessages[$key])) {
             if ('missing' == $show) {
                 continue;
             }
             if (is_array($value) && !is_array($currentMessages[$key])) {
                 $composite['current'] = array($currentMessages[$key]);
             } else {
                 if (!is_array($value) && is_array($currentMessages[$key])) {
                     $composite['current'] = current($currentMessages[$key]);
                 } else {
                     $composite['current'] = $currentMessages[$key];
                 }
             }
         } else {
             if ('translated' == $show) {
                 continue;
             }
             if (is_array($value)) {
                 $composite['current'] = array();
             } else {
                 $composite['current'] = '';
             }
             $missing++;
         }
         // Do search
         if ($search && !$this->_searchArrayRecursive($search, $composite)) {
             continue;
         }
         // Add
         $resultantMessages[] = $composite;
     }
     // Build the paginator
     $this->view->paginator = $paginator = Zend_Paginator::factory($resultantMessages);
     $paginator->setItemCountPerPage(50);
     $paginator->setCurrentPageNumber($page);
     // Process form POST
     if ($this->getRequest()->isPost()) {
         $keys = $this->_getParam('keys');
         $values = $this->_getParam('values');
         // Try to combine the values and keys arrays
         $combined = array();
         foreach ($values as $index => $value) {
             if (is_string($value)) {
                 if (empty($value)) {
                     continue;
                 }
                 $key = $keys[$index];
                 $combined[$key] = $value;
             } else {
                 if (is_array($value)) {
                     if (empty($value) || array_filter($value) === array()) {
                         continue;
                     }
                     $key = $keys[$index][0];
                     $combined[$key] = $value;
                 }
             }
         }
         // Try to write to a file
         $targetFile = APPLICATION_PATH . '/application/languages/' . $locale . '/custom.csv';
         if (!file_exists($targetFile)) {
             touch($targetFile);
             chmod($targetFile, 0777);
         }
         $writer = new Engine_Translate_Writer_Csv($targetFile);
         $writer->setTranslations($combined);
         $writer->write();
         // flush cached language vars
         @Zend_Registry::get('Zend_Cache')->clean();
         // redirect to this same page to get the new values
         return $this->_redirect($_SERVER['REQUEST_URI'], array('prependBase' => false));
     }
 }
示例#25
0
 /**
  * Test that locale names that have been dropped from CLDR continue to
  * work.
  */
 public function testAliases()
 {
     $locale = new Zend_Locale('zh_CN');
     $this->assertEquals(true, $locale->isLocale('zh_CN'));
     $this->assertEquals('zh', $locale->getLanguage());
     $this->assertEquals('CN', $locale->getRegion());
     $this->assertEquals(true, Zend_Locale::isAlias($locale));
     $this->assertEquals(true, Zend_Locale::isAlias('zh_CN'));
     $this->assertEquals('zh_Hans_CN', Zend_Locale::getAlias('zh_CN'));
     $locale = new Zend_Locale('zh_Hans_CN');
     $this->assertEquals(true, $locale->isLocale('zh_Hans_CN'));
     $this->assertEquals('zh', $locale->getLanguage());
     $this->assertEquals('CN', $locale->getRegion());
     $this->assertEquals(false, Zend_Locale::isAlias('zh_Hans_CN'));
     $this->assertEquals('zh_Hans_CN', Zend_Locale::getAlias('zh_Hans_CN'));
 }
示例#26
0
 /**
  * Lang::get_region()
  *
  * Returns the region part of the locale if available
  *
  * @access	public
  * @param	string	$lang	Locale for parsing input
  * @return	string|false	Regionstring
  */
 public function get_region($lang = 'en_US')
 {
     $locale = new Zend_Locale($lang);
     return $locale->getRegion();
 }
示例#27
0
 /**
  * test getEnvironment
  * expected true
  */
 public function testLocaleDetail()
 {
     $value = new Zend_Locale('de_AT');
     $this->assertEquals('de', $value->getLanguage());
     $this->assertEquals('AT', $value->getRegion());
     $value = new Zend_Locale('en_US');
     $this->assertEquals('en', $value->getLanguage());
     $this->assertEquals('US', $value->getRegion());
     $value = new Zend_Locale('en');
     $this->assertEquals('en', $value->getLanguage());
     $this->assertFalse($value->getRegion());
 }
示例#28
0
文件: General.php 项目: hoalangoc/ftf
 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())))), 'filters' => array('StringTrim')));
     $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');
     $this->email->getValidator('EmailAddress')->getHostnameValidator()->setValidateTld(false);
     // Init username
     if (Engine_Api::_()->getApi('settings', 'core')->getSetting('user.signup.username', 1) > 0) {
         $description = Zend_Registry::get('Zend_Translate')->_('This will be the end of your profile link, for example: <br /> ' . '<span id="profile_address">http://%s</span>');
         $description = sprintf($description, $_SERVER['HTTP_HOST'] . Zend_Controller_Front::getInstance()->getBaseUrl() . '/yourname');
         $this->addElement('Text', 'username', array('label' => 'Profile URL', 'description' => $description, 'required' => true, 'allowEmpty' => false, 'validators' => array(array('NotEmpty', true), array('Alnum', true), array('StringLength', true, array(4, 64)), array('Regex', true, array('/^[a-z][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->getDecorator('Description')->setOptions(array('placement' => 'APPEND', 'escape' => false));
         $this->username->getValidator('NotEmpty')->setMessage('Please enter a valid profile url.', 'isEmpty');
         $this->username->getValidator('Db_NoRecordExists')->setMessage('Someone has already picked this profile url, please use another one.', 'recordFound');
         $this->username->getValidator('Regex')->setMessage('Profile url must start with a letter.', 'regexNotMatch');
         $this->username->getValidator('Alnum')->setMessage('Profile url must be alphanumeric.', 'notAlnum');
         // Add banned username validator
         $bannedUsernameValidator = new Engine_Validate_Callback(array($this, 'checkBannedUsername'), $this->username);
         $bannedUsernameValidator->setMessage("This profile url is not available, please use another one.");
         $this->username->addValidator($bannedUsernameValidator);
     }
     // 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) {
         $desc = 'Linking your Facebook account will let you login with Facebook';
         if ('publish' == $facebook_enable) {
             $desc .= ' and publish content to your Facebook wall.';
         } else {
             $desc .= '.';
         }
         $this->addElement('Dummy', 'facebook', array('label' => 'Facebook Integration', 'description' => $desc, '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 Twitter
     $twitter_enable = Engine_Api::_()->getApi('settings', 'core')->getSetting('core_twitter_enable', 'none');
     if ('none' != $twitter_enable) {
         $desc = 'Linking your Twitter account will let you login with Twitter';
         if ('publish' == $twitter_enable) {
             $desc .= ' and publish content to your Twitter feed.';
         } else {
             $desc .= '.';
         }
         $this->addElement('Dummy', 'twitter', array('label' => 'Twitter Integration', 'description' => $desc, 'content' => User_Model_DbTable_Twitter::loginButton('Integrate with my Twitter')));
         $this->addElement('Checkbox', 'twitter_id', array('label' => 'Integrate with my Twitter', 'description' => 'Twitter Integration'));
     }
     $janrain_enable = Engine_Api::_()->getApi('settings', 'core')->getSetting('core_janrain_enable', 'none');
     if ($janrain_enable && $janrain_enable != 'none') {
         // Check if already linked
         $janrainTable = Engine_Api::_()->getDbtable('janrain', 'user');
         $janrainExists = $janrainTable->select()->from($janrainTable, new Zend_Db_Expr('TRUE'))->where('user_id = ?', $this->getItem()->getIdentity())->limit(1)->query()->fetchColumn();
         if (!$janrainExists) {
             $desc = 'Linking another account will let you login using that account.';
             $this->addElement('Dummy', 'janrain', array('label' => 'Social Integration', 'description' => $desc, 'content' => User_Model_DbTable_Janrain::loginButton('page')));
         } else {
             $this->addElement('Radio', 'janrainnoshare', array('label' => 'Share Dialog', 'description' => 'Do you want the option to share a post to ' . 'facebook or twitter to be displayed after posting?', 'multiOptions' => array('0' => 'Yes, display the dialog.', '1' => 'No, do not display the dialog.'), 'value' => 0));
         }
     }
     // 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/Calcutta' => '(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));
     $languages = Engine_Api::_()->getDbTable('languages', 'user')->getLanguagesArray();
     $this->addElement('MultiCheckbox', 'languages', array('label' => 'Language Preference', 'required' => false, 'allowEmpty' => true, 'multiOptions' => $languages, 'filters' => array('StripTags', new Engine_Filter_Censor())));
     // Init submit
     $this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true));
     // Set default action
     $this->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array('module' => 'user', 'controller' => 'settings', 'action' => 'general'), 'default'));
 }
    public function init()
    {
        // Set form attributes
        $description = $this->getTranslator()->translate('Various notification emails are sent to your members as they interact with the community. 
		Use this form to customize the content of these emails. Any changes you make here will 
		only be saved after you click the "Save Changes" button at the bottom of the form. <br>');
        $settings = Engine_Api::_()->getApi('settings', 'core');
        if ($settings->getSetting('user.support.links', 0) == 1) {
            $moreinfo = $this->getTranslator()->translate('More Info: <a href="%1$s" target="_blank"> KB Article</a>');
        } else {
            $moreinfo = $this->getTranslator()->translate('');
        }
        $description = vsprintf($description . $moreinfo, array('http://support.socialengine.com/questions/184/Admin-Panel-Settings-Mail-Templates'));
        // Decorators
        $this->loadDefaultDecorators();
        $this->getDecorator('Description')->setOption('escape', false);
        $this->setTitle('Mail Templates')->setDescription($description);
        // Element: language
        $this->addElement('Select', 'language', array('label' => 'Language Pack', 'description' => 'Your community has more than one language pack installed. Please select the language pack you want to edit right now.', 'onchange' => 'javascript:setEmailLanguage(this.value);'));
        // Languages
        $localeObject = Zend_Registry::get('Locale');
        $translate = Zend_Registry::get('Zend_Translate');
        $languageList = $translate->getList();
        $languages = Zend_Locale::getTranslationList('language', $localeObject);
        $territories = Zend_Locale::getTranslationList('territory', $localeObject);
        $localeMultiOptions = array();
        foreach ($languageList 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 . ']';
            }
        }
        $defaultLanguage = Engine_Api::_()->getApi('settings', 'core')->getSetting('core.locale.locale', 'en');
        if (isset($localeMultiOptions[$defaultLanguage])) {
            $localeMultiOptions = array_merge(array($defaultLanguage => $localeMultiOptions[$defaultLanguage]), $localeMultiOptions);
        }
        $this->language->setMultiOptions($localeMultiOptions);
        // Element: template_id
        $this->addElement('Select', 'template', array('label' => 'Choose Message', 'onchange' => 'javascript:fetchEmailTemplate(this.value);', 'ignore' => true));
        $this->template->getDecorator("Description")->setOption("placement", "append");
        foreach (Engine_Api::_()->getDbtable('MailTemplates', 'core')->fetchAll() as $mailTemplate) {
            $title = $translate->_(strtoupper("_email_" . $mailTemplate->type . "_title"));
            $this->template->addMultiOption($mailTemplate->mailtemplate_id, $title);
        }
        // Element: subject
        $this->addElement('Text', 'subject', array('label' => 'Subject', 'style' => 'min-width:400px;'));
        // Element: body
        $editorOptions = array('html' => (bool) true, 'mode' => "exact", 'forced_root_block' => false, 'force_p_newlines' => false, 'elements' => 'bodyhtml', 'plugins' => array('table', 'fullscreen', 'preview', 'paste', 'code', 'image', 'textcolor', 'link'), 'toolbar1' => array('undo', 'redo', 'removeformat', 'pastetext', '|', 'code', 'image', 'link', 'fullscreen', 'preview'));
        $this->addElement('TinyMce', 'bodyhtml', array('label' => 'Message Body', 'editorOptions' => $editorOptions));
        // Element: submit
        $this->addElement('Button', 'submit', array('label' => 'Save Changes', 'type' => 'submit', 'ignore' => true));
    }
示例#30
0
 /**
  * test getRegionEmpty
  * expected true
  */
 public function testgetRegionEmpty()
 {
     $value = new Zend_Locale('de');
     $this->assertEquals($value->getRegion(), '', 'No region found');
 }