当前位置: 首页>>代码示例>>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;未经允许,请勿转载。