当前位置: 首页>>代码示例>>PHP>>正文


PHP i18n::convert_rfc1766方法代码示例

本文整理汇总了PHP中i18n::convert_rfc1766方法的典型用法代码示例。如果您正苦于以下问题:PHP i18n::convert_rfc1766方法的具体用法?PHP i18n::convert_rfc1766怎么用?PHP i18n::convert_rfc1766使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在i18n的用法示例。


在下文中一共展示了i18n::convert_rfc1766方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Languages

 /**
  * Get a set of content languages (for quick language navigation)
  * @example
  * <code>
  * <!-- in your template -->
  * <ul class="langNav">
  * 		<% loop Languages %>
  * 		<li><a href="$Link" class="$LinkingMode" title="$Title.ATT">$Language</a></li>
  * 		<% end_loop %>
  * </ul>
  * </code>
  *
  * @return ArrayList|null
  */
 public function Languages()
 {
     $locales = TranslatableUtility::get_content_languages();
     // there's no need to show a navigation when there's less than 2 languages. So return null
     if (count($locales) < 2) {
         return null;
     }
     $currentLocale = Translatable::get_current_locale();
     $homeTranslated = null;
     if ($home = SiteTree::get_by_link('home')) {
         /** @var SiteTree $homeTranslated */
         $homeTranslated = $home->getTranslation($currentLocale);
     }
     /** @var ArrayList $langSet */
     $langSet = ArrayList::create();
     foreach ($locales as $locale => $name) {
         Translatable::set_current_locale($locale);
         /** @var SiteTree $translation */
         $translation = $this->owner->hasTranslation($locale) ? $this->owner->getTranslation($locale) : null;
         $langSet->push(new ArrayData(array('Locale' => $locale, 'RFC1766' => i18n::convert_rfc1766($locale), 'Language' => DBField::create_field('Varchar', strtoupper(i18n::get_lang_from_locale($locale))), 'Title' => DBField::create_field('Varchar', html_entity_decode(i18n::get_language_name(i18n::get_lang_from_locale($locale), true), ENT_NOQUOTES, 'UTF-8')), 'LinkingMode' => $currentLocale == $locale ? 'current' : 'link', 'Link' => $translation ? $translation->AbsoluteLink() : ($homeTranslated ? $homeTranslated->Link() : ''))));
     }
     Translatable::set_current_locale($currentLocale);
     i18n::set_locale($currentLocale);
     return $langSet;
 }
开发者ID:bummzack,项目名称:translatable-dataobject,代码行数:39,代码来源:TranslatableUtility.php

示例2: 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

示例3: RFC1766

 public function RFC1766()
 {
     return i18n::convert_rfc1766($this->value);
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:4,代码来源:DBLocale.php

示例4: 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

示例5: ContentLocale

 /**
  * Returns an RFC1766 compliant locale string, e.g. 'fr-CA'.
  * Inspects the associated {@link dataRecord} for a {@link SiteTree->Locale} value if present,
  * and falls back to {@link Translatable::get_current_locale()} or {@link i18n::default_locale()},
  * depending if Translatable is enabled.
  * 
  * Suitable for insertion into lang= and xml:lang=
  * attributes in HTML or XHTML output.
  * 
  * @return string
  */
 function ContentLocale()
 {
     if ($this->dataRecord && $this->dataRecord->hasExtension('Translatable')) {
         $locale = $this->dataRecord->Locale;
     } elseif (Object::has_extension('SiteTree', 'Translatable')) {
         $locale = Translatable::get_current_locale();
     } else {
         $locale = i18n::get_locale();
     }
     return i18n::convert_rfc1766($locale);
 }
开发者ID:hamishcampbell,项目名称:silverstripe-sapphire,代码行数:22,代码来源:ContentController.php

示例6: MetaTags

 /**
  * Returns <link rel="alternate"> markup for insertion into
  * a HTML4/XHTML compliant <head> section, listing all available translations
  * of a page.
  * 
  * @see http://www.w3.org/TR/html4/struct/links.html#edef-LINK
  * @see http://www.w3.org/International/articles/language-tags/
  * 
  * @return string HTML
  */
 function MetaTags(&$tags)
 {
     $template = '<link rel="alternate" type="text/html" title="%s" hreflang="%s" href="%s" />' . "\n";
     $translations = $this->owner->getTranslations();
     if ($translations) {
         foreach ($translations as $translation) {
             $tags .= sprintf($template, $translation->Title, i18n::convert_rfc1766($translation->Locale), $translation->Link());
         }
     }
 }
开发者ID:eLBirador,项目名称:AllAboutCity,代码行数:20,代码来源:Translatable.php

示例7: MetaTags

 /**
  * Returns <link rel="alternate"> markup for insertion into
  * a HTML4/XHTML compliant <head> section, listing all available translations
  * of a page.
  * 
  * @see http://www.w3.org/TR/html4/struct/links.html#edef-LINK
  * @see http://www.w3.org/International/articles/language-tags/
  * 
  * @return string HTML
  */
 public function MetaTags(&$tags)
 {
     $template = '<link rel="alternate" type="text/html" title="%s" hreflang="%s" href="%s" />' . "\n";
     $translations = $this->owner->getTranslations();
     if ($translations) {
         $translations = $translations->toArray();
         $translations[] = $this->owner;
         foreach ($translations as $translation) {
             $tags .= sprintf($template, Convert::raw2xml($translation->Title), i18n::convert_rfc1766($translation->Locale), $translation->AbsoluteLink());
         }
     }
 }
开发者ID:camfindlay,项目名称:silverstripe-translatable,代码行数:22,代码来源:Translatable.php

示例8: getRFC1766Locale

 /**
  * Gets the RFC 1766 version of the input locale
  * @return {string} RFC 1766 version of the locale (i.e en-US)
  */
 public function getRFC1766Locale()
 {
     return i18n::convert_rfc1766($this->owner->Locale);
 }
开发者ID:helpfulrobot,项目名称:webbuilders-group-silverstripe-translatablerouting,代码行数:8,代码来源:MultilingualSiteTreeExtension.php

示例9: MetaTags

 /**
  * Return the title, description, keywords and language metatags.
  * 
  * @todo Move <title> tag in separate getter for easier customization and more obvious usage
  * 
  * @param boolean|string $includeTitle Show default <title>-tag, set to false for custom templating
  * @param boolean $includeTitle Show default <title>-tag, set to false for
  *                              custom templating
  * @return string The XHTML metatags
  */
 public function MetaTags($includeTitle = true)
 {
     $tags = "";
     if ($includeTitle === true || $includeTitle == 'true') {
         $tags .= "<title>" . Convert::raw2xml($this->MetaTitle ? $this->MetaTitle : $this->Title) . "</title>\n";
     }
     $version = new SapphireInfo();
     $tags .= "<meta name=\"generator\" http-equiv=\"generator\" content=\"SilverStripe - http://www.silverstripe.com\" />\n";
     $charset = ContentNegotiator::get_encoding();
     $tags .= "<meta http-equiv=\"Content-type\" content=\"text/html; charset={$charset}\" />\n";
     if ($this->MetaKeywords) {
         $tags .= "<meta name=\"keywords\" http-equiv=\"keywords\" content=\"" . Convert::raw2att($this->MetaKeywords) . "\" />\n";
     }
     if ($this->MetaDescription) {
         $tags .= "<meta name=\"description\" http-equiv=\"description\" content=\"" . Convert::raw2att($this->MetaDescription) . "\" />\n";
     }
     if ($this->ExtraMeta) {
         $tags .= $this->ExtraMeta . "\n";
     }
     // get the "long" lang name suitable for the HTTP content-language flag (with hyphens instead of underscores)
     $currentLang = $this->hasExtension('Translatable') ? Translatable::get_current_locale() : i18n::get_locale();
     $tags .= "<meta http-equiv=\"Content-Language\" content=\"" . i18n::convert_rfc1766($currentLang) . "\"/>\n";
     // DEPRECATED 2.3: Use MetaTags
     $this->extend('updateMetaTags', $tags);
     $this->extend('MetaTags', $tags);
     return $tags;
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:37,代码来源:SiteTree.php

示例10: getAllTranslations

 /**
  * Returns all translated locales as a special ArrayList
  *
  * @return ArrayList 
  */
 public function getAllTranslations()
 {
     $currentLocale = Translatable::get_current_locale();
     $translations = $this->getTranslations();
     $translationSource = new ArrayList();
     if ($translations) {
         $translationSource->push(new DataObject(array('Name' => SilvercartLanguageHelper::getLanguageName($currentLocale, $currentLocale), 'NativeName' => SilvercartLanguageHelper::getLanguageName($currentLocale, $currentLocale), 'Code' => $this->getIso2($currentLocale), 'RFC1766' => i18n::convert_rfc1766($currentLocale), 'Link' => $this->Link())));
         foreach ($translations as $translation) {
             $translationSource->push(new DataObject(array('Name' => SilvercartLanguageHelper::getLanguageName($translation->Locale, $currentLocale), 'NativeName' => SilvercartLanguageHelper::getLanguageName($translation->Locale, $translation->Locale), 'Code' => $this->getIso2($translation->Locale), 'RFC1766' => i18n::convert_rfc1766($translation->Locale), 'Link' => $translation->Link())));
         }
     }
     return $translationSource;
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:18,代码来源:SilvercartPage.php


注:本文中的i18n::convert_rfc1766方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。