コード例 #1
0
 public function init()
 {
     $this->setTitle('Language Pack')->setDescription('Upload a modified language pack.  This will overwrite any language entries already in a language file.')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));
     $languageList = Zend_Locale_Data::getList('en', 'language');
     $territoryList = Zend_Locale_Data::getList('en', 'territory');
     $languageNameList = array();
     foreach (array_keys(Zend_Locale::getLocaleList()) as $localeCode) {
         $localeArray = explode('_', $localeCode);
         $locale = array_shift($localeArray);
         $territory = array_shift($localeArray);
         if (isset($languageList[$locale]) && !empty($languageList[$locale])) {
             $languageNameList[$localeCode] = $languageList[$locale];
             if (isset($territoryList[$territory]) && !empty($territoryList[$territory])) {
                 $languageNameList[$localeCode] .= " ({$territoryList[$territory]})";
             }
             $languageNameList[$localeCode] .= "  [{$localeCode}]";
         }
     }
     asort($languageNameList);
     $this->addElement('Select', 'locale', array('label' => 'Language', 'description' => 'Which language will this language pack be applied to?', 'multiOptions' => $languageNameList));
     $this->addElement('File', 'file', array('label' => 'Language File', 'description' => 'Upload a language CSV file.', 'required' => true));
     // Init submit
     $this->addElement('Button', 'submit', array('label' => 'Upload', 'type' => 'submit', 'decorators' => array('ViewHelper')));
     $this->addElement('Cancel', 'cancel', array('prependText' => ' or ', 'link' => true, 'label' => 'cancel', 'onclick' => 'history.go(-1); return false;', 'decorators' => array('ViewHelper')));
 }
コード例 #2
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')));
 }
コード例 #3
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));
 }
コード例 #4
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'));
 }
コード例 #5
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;
 }
コード例 #6
0
 /**
  * Add a sample message to a particular event for a particular Locale.
  *
  * Eg: addSampleMessage(1, 'en_US', 'Hey $NAME$ - Your Order has shipped!'
  *
  * @param $eventIdOrName $eventId
  * @param string $localeCode
  * @param string $message
  */
 public function addSampleMessage($eventIdOrName, $localeCode, $message)
 {
     if (!is_int($eventIdOrName) && !is_string($eventIdOrName)) {
         throw new InvalidArgumentException(sprintf('Invalid Event ID. Expected: string or int, got: "%s"', is_object($eventIdOrName) ? get_class($eventIdOrName) : gettype($eventIdOrName)));
     }
     if (!is_string($localeCode)) {
         throw new InvalidArgumentException(sprintf('Invalid Locale. Expected: "%s", got: "%s"', is_object($localeCode) ? get_class($localeCode) : gettype($localeCode)));
     }
     $locales = Zend_Locale::getLocaleList();
     if (!isset($locales[$localeCode])) {
         throw new InvalidArgumentException(sprintf('Invalid Locale. "%s" is not a valid Locale', $localeCode));
     }
     if (!is_string($message)) {
         throw new InvalidArgumentException(sprintf('Invalid Message Template. Expected: "%s", got: "%s"', is_object($message) ? get_class($message) : gettype($message)));
     }
     $eventId = $eventIdOrName;
     if (!is_int($eventIdOrName)) {
         $event = $this->loadEvent($eventIdOrName);
         if (!is_array($event)) {
             throw new \InvalidArgumentException(sprintf('Cannot find event with name: "%s"', $eventIdOrName));
         }
         $eventId = $event['entity_id'];
     }
     $this->getConnection()->insert($this->getTable('esendex_sms/event_sample_message_template'), array('event_id' => $eventId, 'locale_code' => $localeCode, 'message_template' => $message));
     //Flush Event Collection from Cache
     Mage::app()->getCacheInstance()->clean(array(Esendex_Sms_Model_Event::CACHE_TAG));
 }
コード例 #7
0
ファイル: Cldr.php プロジェクト: fkomaralp/country-list
 /**
  * {@inheritdoc}
  */
 public function getLanguages()
 {
     return array_keys(\Zend_Locale::getLocaleList());
 }
コード例 #8
0
ファイル: locales.php プロジェクト: sabril-2t/Open-Ad-Server
 /**
  * Get languages by locale
  *
  * @param String $locale
  * @return Array
  */
 public function getLanguagesByLocale($locale)
 {
     $tmp_locales = Zend_Locale::getLocaleList();
     if (!isset($tmp_locales[$locale])) {
         return array();
     }
     return Zend_Locale::getTranslationList('language', $locale);
 }
コード例 #9
0
 /**
  * List of all locales.
  *
  * @param string $locale
  * @access public
  * @return array
  * @static
  *
  * @author Etienne de Longeaux <*****@*****.**>
  */
 public static function allLocales($locale)
 {
     $localelist = \Zend_Locale::getLocaleList();
     $name_key = array_map(function ($key, $locale) {
         return locale_get_display_name(strtolower($key), strtolower($locale)) . " - ({$key})";
     }, array_keys($localelist), array_fill(0, count($localelist) - 1, $locale));
     return array_combine(array_keys($localelist), $name_key);
 }
コード例 #10
0
ファイル: setup.php プロジェクト: Zyqsempai/amanet
 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;
 }
コード例 #11
0
 /**
  * Return array of locales, supported by the theme
  *
  * @param \Magento\Framework\View\Design\ThemeInterface $theme
  * @return array
  */
 protected static function _getThemeLocales(\Magento\Framework\View\Design\ThemeInterface $theme)
 {
     $result = array();
     $patternDir = self::_getLocalePatternDir($theme);
     $localeModel = new \Zend_Locale();
     foreach (array_keys($localeModel->getLocaleList()) as $locale) {
         $dir = str_replace('<locale_placeholder>', $locale, $patternDir);
         if (is_dir($dir)) {
             $result[] = $locale;
         }
     }
     return $result;
 }
コード例 #12
0
ファイル: localization.php プロジェクト: Zyqsempai/amanet
 /**
  * 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;
 }
コード例 #13
0
ファイル: Translations.php プロジェクト: bombayworks/currycms
 /**
  * Show edit language.
  */
 public function showLanguages()
 {
     $this->addMainMenu();
     $langcodes = array();
     foreach (Zend_Locale::getLocaleList() as $langcode => $ignore) {
         list($l, $t) = explode('_', $langcode);
         $language = Zend_Locale::getTranslation($l, 'language', 'en_US');
         if (!$language) {
             $language = $langcode;
         }
         $territory = $t ? Zend_Locale::getTranslation($t, 'territory', 'en_US') : '';
         $langcodes[$langcode] = $language . ($territory ? " ({$territory})" : ' (Generic)');
     }
     $existing = LanguageQuery::create()->find()->toKeyValue('Langcode', 'Name');
     foreach ($existing as $langcode => $name) {
         if (!array_key_exists($langcode, $langcodes)) {
             $langcodes[$langcode] = $name . ' (Custom)';
         }
     }
     asort($langcodes);
     $form = new Curry_ModelView_Form('Language', array('ignorePks' => false, 'columnElements' => array('langcode' => array('select', array('multiOptions' => $langcodes, 'disable' => array_keys($existing), 'onchange' => "\$('[name=\"name\"]', this.form).val(this.options[this.selectedIndex].text);"))), 'onFillForm' => function ($item, $form) {
         if ($item->isNew()) {
             $form->addElement('select', 'copy', array('label' => 'Copy translations from', 'multiOptions' => array('' => '[ None ]') + LanguageQuery::create()->find()->toKeyValue('PrimaryKey', 'Name'), 'order' => 2));
         } else {
             // Prevent changing langcode (propel cant change primary keys anyway)
             $form->removeElement('langcode');
         }
     }, 'onFillModel' => function (Language $item, $form, $values) {
         $user = User::getUser();
         if ($item->isNew()) {
             $item->addUser($user);
             if (isset($values['copy']) && $values['copy']) {
                 $translations = LanguageStringTranslationQuery::create()->findByLangcode($values['copy']);
                 foreach ($translations as $translation) {
                     $item->addLanguageStringTranslation($translation->copy());
                 }
             }
         }
     }));
     $list = new Curry_ModelView_List('Language', array('modelForm' => $form, 'maxPerPage' => 0));
     $this->addMainContent($list);
 }
コード例 #14
0
ファイル: add.php プロジェクト: dadigo/simpleinvoices
<?php

//stop the direct browsing to this file - let index.php handle which files get displayed
checkLogin();
//if valid then do save
if ($_POST['p_description'] != "") {
    include "./modules/preferences/save.php";
}
$smarty->assign('save', $save);
$defaults = getSystemDefaults();
$preferences = getActivePreferences();
$localelist = Zend_Locale::getLocaleList();
$smarty->assign('preferences', $preferences);
$smarty->assign('defaults', $defaults);
$smarty->assign('localelist', $localelist);
$smarty->assign('pageActive', 'preference');
$smarty->assign('subPageActive', 'preferences_add');
$smarty->assign('active_tab', '#setting');
コード例 #15
0
 public function init()
 {
     $this->setTitle('Translate Language')->setDescription('Translate a language pack using Google Translate.')->setAction(Zend_Controller_Front::getInstance()->getRouter()->assemble(array()));
     // Build language list
     $translate = Zend_Registry::get('Zend_Translate');
     //$translate        = new Zend_Translate_Adapter();
     $languageList = Zend_Locale_Data::getList('en', 'language');
     $territoryList = Zend_Locale_Data::getList('en', 'territory');
     //var_dump(array_intersect(Engine_Service_GTranslate::getAvailableLanguages(), array_keys($languageList)));
     //var_dump(array_diff(Engine_Service_GTranslate::getAvailableLanguages(), array_keys($languageList)));
     //var_dump(array_diff(array_keys($languageList), Engine_Service_GTranslate::getAvailableLanguages()));
     //die();
     $languageNameList = array();
     foreach (array_keys(Zend_Locale::getLocaleList()) as $localeCode) {
         $lang_array = explode('_', $localeCode);
         $locale = array_shift($lang_array);
         $territory = array_shift($lang_array);
         // Full locale
         $languageName = null;
         if (isset($languageList[$localeCode])) {
             $languageName = $languageList[$locale] . ' [' . $localeCode . ']';
         } else {
             if (isset($languageList[$locale])) {
                 $languageName = $languageList[$locale];
                 if (!empty($territoryList[$territory])) {
                     $languageName .= ' (' . $territoryList[$territory] . ')';
                 }
                 $languageName .= ' [' . $localeCode . ']';
             } else {
                 //$languageName = '[' . $localeCode . ']';
             }
         }
         // Check against gtranslate
         if (!Engine_Service_GTranslate::isAvailableLanguage($localeCode)) {
             continue;
             //} else if( !Engine_Service_GTranslate::testAvailableLanguage($localeCode) ) {
             //  echo 'Bad: ' . $localeCode . '<br />' . PHP_EOL;
             //  continue;
             //} else {
             //  echo 'Good: ' . $localeCode . '<br />' . PHP_EOL;
         }
         if ($languageName) {
             $languageNameList[$localeCode] = $languageName;
         }
     }
     asort($languageNameList);
     // Let's pull the existing languages to the top?
     $existingLanguageNameList = array();
     $notExistingLanguageNameList = array();
     foreach ($translate->getList() as $locale) {
         if (isset($languageNameList[$locale])) {
             $existingLanguageNameList[$locale] = $languageNameList[$locale];
         }
     }
     $notExistingLanguageNameList = array_diff_key($languageNameList, $existingLanguageNameList);
     //$languageNameList = array_merge($existingLanguageNameList, $languageNameList);
     $targetMultiOptions = array_merge($existingLanguageNameList, $notExistingLanguageNameList);
     $targetMultiOptions = array('Translated' => $existingLanguageNameList, 'Untranslated' => $notExistingLanguageNameList, 'Special' => array('all' => 'All Available', 'all-translated' => 'All Translated', 'all-untranslated' => 'All Untranslated'));
     // Element: source
     $this->addElement('Select', 'source', array('label' => 'Source language', 'value' => 'en', 'required' => true, 'allowEmpty' => false));
     foreach ($translate->getList() as $locale) {
         if (!Engine_Service_GTranslate::isAvailableLanguage($locale)) {
             continue;
         }
         $this->source->addMultiOption($locale, @$languageNameList[$locale] ? $languageNameList[$locale] : $locale);
     }
     // Element: target
     $this->addElement('Select', 'target', array('label' => 'Target Language', 'multiOptions' => array_merge(array('' => ''), $targetMultiOptions), 'required' => true, 'allowEmpty' => false));
     // Element: batchCount
     $this->addElement('Text', 'batchCount', array('label' => 'Batch Count', 'allowEmpty' => false, 'validators' => array('Int'), 'value' => 50));
     // Element: overwrite
     $this->addElement('Radio', 'overwrite', array('label' => 'Retranslate', 'description' => 'Do you want to retranslate existing phrases?', 'multiOptions' => array('1' => 'Yes', '0' => 'No'), 'value' => '0'));
     // Element: test
     $this->addElement('Text', 'test', array('label' => 'Test Translation', 'description' => 'Test Translation'));
     // Element: submit
     $this->addElement('Button', 'submit', array('label' => 'Translate', 'type' => 'submit', 'decorators' => array('ViewHelper')));
     // Element: cancel
     $this->addElement('Cancel', 'cancel', array('prependText' => ' or ', 'link' => true, 'label' => 'cancel', 'onclick' => 'history.go(-1); return false;', 'decorators' => array('ViewHelper')));
     // DisplayGroup: buttons
     $this->addDisplayGroup(array('submit', 'cancel'), 'buttons');
 }
コード例 #16
0
ファイル: Locale.php プロジェクト: rguedes/axiscommerce
 /**
  * @static
  * @return array
  */
 public static function getInstallLocaleList()
 {
     $options = array();
     $locales = Zend_Locale::getLocaleList();
     $languages = Zend_Locale::getTranslationList('language', self::getLocale());
     $countries = Zend_Locale::getTranslationList('territory', self::getLocale(), 2);
     foreach ($locales as $code => $is_active) {
         if (strstr($code, '_')) {
             $data = explode('_', $code);
             if (!isset($languages[$data[0]]) || !isset($countries[$data[1]])) {
                 continue;
             }
             $options[$code] = ucfirst($languages[$data[0]]) . ' (' . $countries[$data[1]] . ')';
         }
     }
     return $options;
 }
コード例 #17
0
ファイル: Culture.php プロジェクト: massimozappino/zmz
 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;
 }
コード例 #18
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'));
 }
コード例 #19
0
ファイル: LocaleTest.php プロジェクト: jon9872/zend-framework
 /**
  * test isLocale
  * expected boolean
  */
 public function testGetLocaleList()
 {
     $this->assertTrue(is_array(Zend_Locale::getLocaleList()));
 }
コード例 #20
0
 public function getForm()
 {
     $languageTranslation = Am_Locale::getSelfNames();
     $avalableLocaleList = Zend_Locale::getLocaleList();
     $existingLanguages = Am_Di::getInstance()->languagesListUser;
     $languageOptions = array();
     foreach ($avalableLocaleList as $k => $v) {
         $locale = new Zend_Locale($k);
         if (!array_key_exists($locale->getLanguage(), $existingLanguages) && isset($languageTranslation[$locale->getLanguage()])) {
             $languageOptions[$locale->getLanguage()] = "({$k}) " . $languageTranslation[$locale->getLanguage()];
         }
     }
     asort($languageOptions);
     $form = new Am_Form_Admin();
     $form->setAction($this->grid->makeUrl(null));
     $form->addElement('select', 'new_language')->setLabel(___('Language'))->loadOptions($languageOptions)->setId('languageSelect');
     $form->addElement('hidden', 'a')->setValue('new');
     $form->addSaveButton();
     foreach ($this->grid->getVariablesList() as $k) {
         if ($val = $this->grid->getRequest()->get($k)) {
             $form->addHidden($this->grid->getId() . '_' . $k)->setValue($val);
         }
     }
     return $form;
 }