當前位置: 首頁>>代碼示例>>PHP>>正文


PHP i18n::get_locale_name方法代碼示例

本文整理匯總了PHP中i18n::get_locale_name方法的典型用法代碼示例。如果您正苦於以下問題:PHP i18n::get_locale_name方法的具體用法?PHP i18n::get_locale_name怎麽用?PHP i18n::get_locale_name使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在i18n的用法示例。


在下文中一共展示了i18n::get_locale_name方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: CurrentLocaleInformation

 /**
  * Retrieves information about this object in the CURRENT locale
  *
  * @param string $locale The locale information to request, or null to use the default locale
  * @return ArrayData Mapped list of locale properties
  */
 public function CurrentLocaleInformation()
 {
     $locale = Fluent::current_locale();
     // Store basic locale information
     $data = array('Locale' => $locale, 'LocaleRFC1766' => i18n::convert_rfc1766($locale), 'Alias' => Fluent::alias($locale), 'Title' => i18n::get_locale_name($locale), 'LanguageNative' => i18n::get_language_name(i18n::get_lang_from_locale($locale), true));
     return new ArrayData($data);
 }
開發者ID:micschk,項目名稱:silverstripe-cmstweaks,代碼行數:13,代碼來源:PageHelpersExtension.php

示例2: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     //adding upload field - if item has already been saved
     if ($this->ID && $this->AssetsFolderID != 0) {
         //this is the default, for non multi-language sites
         if (!class_exists('Translatable') || $this->Locale == Translatable::default_locale()) {
             //Use SortableUploadField instead of UploadField!
             //The upload directory is expected to have been set in {@see UploadDirRules},
             //and should be something like: "assets/ID-Pagename"
             //TODO: This could easily be configurable through yml files (to e.g. "assets/galleries/ID"),
             //so this module could do without the upload dir rules
             //
             //read more about adding additinoal metadata to images here:
             //http://doc.silverstripe.org/framework/en/reference/uploadfield
             $imageField = new SortableUploadField('Images', '');
             $fields->addFieldToTab('Root.Images', $imageField);
         } else {
             $orig = $this->getTranslation(Translatable::default_locale());
             $html = sprintf('<a href="%s">%s</a>', Controller::join_links($orig->CMSEditLink(), '?locale=' . $orig->Locale), 'Images are administered through ' . i18n::get_locale_name($orig->Locale));
             $fields->addFieldToTab('Root.Images', LiteralField::create('ImagesDesc', $html));
         }
     }
     return $fields;
 }
開發者ID:helpfulrobot,項目名稱:titledk-silverstripe-gallery,代碼行數:25,代碼來源:GalleryPage.php

示例3: getLanguageField

 /**
  * @return mixed
  */
 public function getLanguageField()
 {
     $locale = Translatable::get_current_locale();
     if ($member = Member::currentUser()) {
         if (Permission::checkMember($member, 'VIEW_LANGS')) {
             return $this->getLanguageDropdownField($locale);
         }
     }
     return LiteralField::create('Locale', i18n::get_locale_name($locale));
 }
開發者ID:littlegiant,項目名稱:silverstripe-catalogmanager,代碼行數:13,代碼來源:TranslatableCatalogExtension.php

示例4: updateSettingsFields

 public function updateSettingsFields(FieldList $fields)
 {
     // Present a set of checkboxes for filtering this item by locale
     $menuFilterField = FieldGroup::create()->setTitle($this->owner->fieldLabel('ShowInMenus'))->setDescription(_t('Fluent.LocaleMenuFilterDescription', 'Select the locales where this item is visible in the menu'));
     foreach (Fluent::locales() as $locale) {
         $id = Fluent::db_field_for_locale("ShowInMenus", $locale);
         $fields->removeByName($id, true);
         // Remove existing (in case it was auto scaffolded)
         $title = i18n::get_locale_name($locale);
         $menuFilterField->push(new CheckboxField($id, $title));
     }
     $fields->removeByName('ShowInMenus', true);
     $fields->addFieldToTab('Root.Settings', $menuFilterField, 'CanViewType');
 }
開發者ID:Digitweaks,項目名稱:silverstripe-fluent,代碼行數:14,代碼來源:FluentMenuExtension.php

示例5: updateSearchForm

 /**
  * Returns a form with all languages with languages already used appearing first.
  *
  * @return Form
  */
 public function updateSearchForm(Form $form)
 {
     $member = Member::currentUser();
     //check to see if the current user can switch langs or not
     if (Permission::checkMember($member, 'VIEW_LANGS')) {
         $field = new LanguageDropdownField('Locale', _t('CMSMain.LANGUAGEDROPDOWNLABEL', 'Language'), array(), 'SiteTree', 'Locale-English', singleton('SiteTree'));
         $field->setValue(Translatable::get_current_locale())->setForm($form);
     } else {
         // user doesn't have permission to switch langs
         // so just show a string displaying current language
         $field = new LiteralField('Locale', i18n::get_locale_name(Translatable::get_current_locale()));
     }
     $form->Fields()->unshift($field);
 }
開發者ID:webtorque7,項目名稱:inpage-modules,代碼行數:19,代碼來源:ContentModuleMainTranslatableExtension.php

示例6: LangForm

 /**
  * Returns a form with all languages with languages already used appearing first.
  *
  * @return Form
  */
 function LangForm()
 {
     $member = Member::currentUser();
     //check to see if the current user can switch langs or not
     if (Permission::checkMember($member, 'VIEW_LANGS')) {
         $field = new LanguageDropdownField('Locale', _t('CMSMain.LANGUAGEDROPDOWNLABEL', 'Language'), array(), 'SiteTree', 'Locale-English', singleton('SiteTree'));
         $field->setValue(Translatable::get_current_locale());
     } else {
         // user doesn't have permission to switch langs
         // so just show a string displaying current language
         $field = new LiteralField('Locale', i18n::get_locale_name(Translatable::get_current_locale()));
     }
     $form = new Form($this->owner, 'LangForm', new FieldList($field), new FieldList(new FormAction('selectlang', _t('CMSMain_left.GO', 'Go'))));
     $form->unsetValidator();
     $form->addExtraClass('nostyle');
     return $form;
 }
開發者ID:helpfulrobot,項目名稱:dospuntocero-silverstripe-catalogmanager,代碼行數:22,代碼來源:TranslatableCatalogExtension.php

示例7: preRequest

 public function preRequest(\SS_HTTPRequest $request, \Session $session, \DataModel $model)
 {
     // Check languages to set
     $languages = array();
     foreach (SpellController::get_locales() as $locale) {
         $languages[] = i18n::get_locale_name($locale) . '=' . $locale;
     }
     // Set settings
     $editor = Config::inst()->get(__CLASS__, 'editor');
     HtmlEditorConfig::get($editor)->enablePlugins('spellchecker');
     HtmlEditorConfig::get($editor)->addButtonsToLine(2, 'spellchecker');
     $token = SecurityToken::inst();
     HtmlEditorConfig::get($editor)->setOption('spellchecker_rpc_url', $token->addToUrl('spellcheck/'));
     HtmlEditorConfig::get($editor)->setOption('browser_spellcheck', false);
     HtmlEditorConfig::get($editor)->setOption('spellchecker_languages', '+' . implode(', ', $languages));
     return true;
 }
開發者ID:helpfulrobot,項目名稱:silverstripe-spellcheck,代碼行數:17,代碼來源:SpellRequestFilter.php

示例8: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     // Present a set of checkboxes for filtering this item by locale
     $filterField = FieldGroup::create()->setTitle(_t('Fluent.LocaleFilter', 'Locale Filter'))->setDescription(_t('Fluent.LocaleFilterDescription', 'Check a locale to show this item on that locale'));
     foreach (Fluent::locales() as $locale) {
         $id = Fluent::db_field_for_locale("LocaleFilter", $locale);
         $fields->removeByName($id, true);
         // Remove existing (in case it was auto scaffolded)
         $title = i18n::get_locale_name($locale);
         $filterField->push(new CheckboxField($id, $title));
     }
     if ($fields->hasTabSet()) {
         $fields->findOrMakeTab('Root.Locales', _t('Fluent.TABLOCALES', 'Locales'));
         $fields->addFieldToTab('Root.Locales', $filterField);
     } else {
         $fields->add($filterField);
     }
 }
開發者ID:tractorcow,項目名稱:silverstripe-fluent,代碼行數:18,代碼來源:FluentFilteredExtension.php

示例9: updateCMSFields

 /**
  * @param FieldList $fields
  */
 public function updateCMSFields(FieldList $fields)
 {
     //adding upload field - if item has already been saved
     //AssetsFolderID is set by the uploaddirrules module
     if ($this->owner->ID && $this->owner->AssetsFolderID != 0) {
         //this is the default, for non multi-language sites
         if (!class_exists('Translatable') || $this->owner->Locale == Translatable::default_locale()) {
             //The upload directory is expected to have been set in {@see UploadDirRules},
             //This should be handled on the object that uses this extension!
             $imageField = SortableUploadField::create('Images', '')->setAllowedFileCategories('image');
             $fields->addFieldToTab('Root.Images', $imageField);
         } else {
             //Note that images are administered in the original language
             $orig = $this->owner->getTranslation(Translatable::default_locale());
             $html = sprintf('<a href="%s">%s</a>', Controller::join_links($orig->CMSEditLink(), '?locale=' . $orig->Locale), 'Images are administered through ' . i18n::get_locale_name($orig->Locale));
             $fields->addFieldToTab('Root.Images', LiteralField::create('ImagesDesc', $html));
         }
     }
 }
開發者ID:titledk,項目名稱:silverstripe-gallery,代碼行數:22,代碼來源:GalleryExtension.php

示例10: init

 public function init()
 {
     parent::init();
     // Locale" attribute is either explicitly added by LeftAndMain Javascript logic,
     // or implied on a translated record (see {@link Translatable->updateCMSFields()}).
     // $Lang serves as a "context" which can be inspected by Translatable - hence it
     // has the same name as the database property on Translatable.
     if ($this->getRequest()->requestVar("Locale")) {
         $this->Locale = $this->getRequest()->requestVar("Locale");
     } elseif ($this->getRequest()->requestVar("locale")) {
         $this->Locale = $this->getRequest()->requestVar("locale");
     } else {
         $this->Locale = Translatable::default_locale();
     }
     Translatable::set_current_locale($this->Locale);
     // collect languages for TinyMCE spellchecker plugin.
     // see http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/spellchecker
     $langName = i18n::get_locale_name($this->Locale);
     HtmlEditorConfig::get('cms')->setOption('spellchecker_languages', "+{$langName}={$this->Locale}");
     Requirements::javascript(CMS_DIR . '/javascript/CMSMain.js');
     Requirements::javascript(CMS_DIR . '/javascript/CMSMain_left.js');
     Requirements::javascript(CMS_DIR . '/javascript/CMSMain_right.js');
 }
開發者ID:SustainableCoastlines,項目名稱:loveyourwater,代碼行數:23,代碼來源:CMSMain.php

示例11: providePermissions

 function providePermissions()
 {
     if (!Object::has_extension('SiteTree', 'Translatable')) {
         return false;
     }
     $locales = self::get_allowed_locales();
     // Fall back to any locales used in existing translations (see #4939)
     if (!$locales) {
         $locales = DB::query('SELECT "Locale" FROM "SiteTree" GROUP BY "Locale"')->column();
     }
     $permissions = array();
     if ($locales) {
         foreach ($locales as $locale) {
             $localeName = i18n::get_locale_name($locale);
             $permissions['TRANSLATE_' . $locale] = sprintf(_t('Translatable.TRANSLATEPERMISSION', 'Translate %s', PR_MEDIUM, 'Translate pages into a language'), $localeName);
         }
     }
     $permissions['TRANSLATE_ALL'] = _t('Translatable.TRANSLATEALLPERMISSION', 'Translate into all available languages');
     return $permissions;
 }
開發者ID:eLBirador,項目名稱:AllAboutCity,代碼行數:20,代碼來源:Translatable.php

示例12: ActiveLocalesNames

 /**
  * Return a list of actives locales
  * 
  * @return array
  */
 public function ActiveLocalesNames()
 {
     $locales = array();
     $list = $this->owner->ActiveLocales;
     if (!$list) {
         return Fluent::locale_names();
     }
     foreach (explode(',', $list) as $locale) {
         $locales[$locale] = i18n::get_locale_name($locale);
     }
     return $locales;
 }
開發者ID:lekoala,項目名稱:silverstripe-devtoolkit,代碼行數:17,代碼來源:ActiveLocalesExtension.php

示例13: translate

 public function translate(SS_HTTPRequest $request)
 {
     $locales = "";
     if (SiteTree::has_extension("Translatable")) {
         $locales = Translatable::get_allowed_locales();
     } else {
         $locales = array("it_IT");
     }
     $locales_list = new ArrayList();
     foreach ($locales as $key => $value) {
         $obj = new ViewableData();
         $obj->__set("Locale", $value);
         $obj->__set("LocaleName", i18n::get_locale_name($value));
         $obj->__set("Lang", i18n::get_lang_from_locale($value));
         $locales_list->push($obj);
     }
     if ($request->isAjax()) {
         if (isset($_POST["collect"])) {
             foreach ($locales as $value) {
                 $c = new TextCollector($value);
                 $c->run(LanguageAdmin::$modules, true);
             }
             die(_t("SUCCESSFULL_COLLECT", "The text was collected."));
         }
         if (isset($_POST["save"])) {
             $lang_array[$_POST["locale"]] = $_POST[$_POST["locale"]];
             $file = $_POST["file"];
             $yml_file = sfYaml::dump($lang_array);
             if ($fh = fopen($file, "w")) {
                 fwrite($fh, $yml_file);
                 fclose($fh);
                 file_get_contents("http://{$_SERVER['HTTP_HOST']}?flush");
             } else {
                 throw new LogicException("Cannot write language file! Please check permissions of {$langFile}");
             }
             die;
         }
         $files = $this->getFiles();
         if (isset($_POST["loadfiles"])) {
             //  die($this->getYaml($_POST["loadfiles"]));
             $this->customise(array("Translations" => $this->getYaml($_POST["loadfiles"]), "Modules" => $files, "Locales" => $locales_list));
             $content = $this->renderWith('LanguageAdmin_Content');
             return $content;
         } else {
             $this->customise(array("Modules" => $files, "Translations" => $this->getYaml($files->filter(array('Locale' => $locales_list->first()->Locale))->first()->Path), "Locales" => $locales_list, "CurrentLocale" => $locales_list->first()->LocaleName));
             $content = $this->renderWith('LanguageAdmin_Content');
             return $content;
         }
     } else {
         $files = $this->getFiles();
         $this->customise(array("Modules" => $files, "Translations" => $this->getYaml($files->filter(array('Locale' => $locales_list->first()->Locale))->first()->Path), "Locales" => $locales_list, "CurrentLocale" => $locales_list->first()->LocaleName));
         $content = $this->renderWith($this->getViewer('translate'));
         return $content;
     }
 }
開發者ID:helpfulrobot,項目名稱:calinhoria-langedit,代碼行數:55,代碼來源:LanguageAdmin.php

示例14: LocaleInformation

 /**
  * Retrieves information about this object in the specified locale
  *
  * @param string $locale The locale information to request, or null to use the default locale
  * @return ArrayData Mapped list of locale properties
  */
 public function LocaleInformation($locale = null)
 {
     // Check locale
     if (empty($locale)) {
         $locale = Fluent::default_locale();
     }
     // Check linking mode
     $linkingMode = 'link';
     if ($this->owner->hasMethod('canViewInLocale') && !$this->owner->canViewInLocale($locale)) {
         $linkingMode = 'invalid';
     } elseif ($locale === Fluent::current_locale()) {
         $linkingMode = 'current';
     }
     // Check link
     $link = $this->owner->LocaleLink($locale);
     // Store basic locale information
     $data = array('Locale' => $locale, 'LocaleRFC1766' => i18n::convert_rfc1766($locale), 'Alias' => Fluent::alias($locale), 'Title' => i18n::get_locale_name($locale), 'LanguageNative' => i18n::get_language_name(i18n::get_lang_from_locale($locale), true), 'Link' => $link, 'AbsoluteLink' => $link ? Director::absoluteURL($link) : null, 'LinkingMode' => $linkingMode);
     return new ArrayData($data);
 }
開發者ID:Digitweaks,項目名稱:silverstripe-fluent,代碼行數:25,代碼來源:FluentExtension.php

示例15: locale_names

 /**
  * Retrieves the list of locale names as an associative array
  *
  * @return array List of locale names mapped by locale code
  */
 public static function locale_names()
 {
     $locales = array();
     foreach (self::locales() as $locale) {
         $locales[$locale] = i18n::get_locale_name($locale);
     }
     return $locales;
 }
開發者ID:helpfulrobot,項目名稱:tractorcow-silverstripe-fluent,代碼行數:13,代碼來源:Fluent.php


注:本文中的i18n::get_locale_name方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。