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


PHP Locale::getDisplayName方法代码示例

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


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

示例1: finishView

 /**
  * {@inheritdoc}
  */
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     if ($form->getConfig()->hasAttribute('prototype') && $view->vars['prototype']->vars['multipart']) {
         $view->vars['multipart'] = true;
     }
     $options = $form->getConfig()->getOptions();
     $view->vars['null_locale_enabled'] = $options['null_locale_enabled'];
     $view->vars['null_locale_selected'] = $options['null_locale_selected'];
     $requestLocale = $this->getRequestLocale();
     $view->vars['locale_titles'] = array();
     foreach ($options['locales'] as $locale) {
         $view->vars['locale_titles'][$locale] = \Locale::getDisplayName($locale, $requestLocale);
     }
     $request = $this->getRequest();
     if (null === $request) {
         $current_selected_lang = $options['locales'][0];
     } else {
         $current_selected_lang = $request->cookies->get('current_selected_translation_lang', null);
         $selectedLanguageIsNotValid = $current_selected_lang !== '__all__' && !in_array($current_selected_lang, $options['locales']);
         if ($current_selected_lang === null || $selectedLanguageIsNotValid) {
             $current_selected_lang = $options['locales'][0];
         }
     }
     $view->vars['current_selected_lang'] = $current_selected_lang;
 }
开发者ID:nercury,项目名称:translation-editor-bundle,代码行数:28,代码来源:TranslationsEditorType.php

示例2: enabledLocales

 /**
  * Return the enabled locales suitable for local choosing.
  *
  * @return array Returns an array in the form `[locale => localeName]`.
  */
 public static function enabledLocales()
 {
     $defaultLocale = Gdn_Locale::Canonicalize(C('Garden.Locale'));
     $localeModel = new LocaleModel();
     if (class_exists('Locale')) {
         $localePacks = $localeModel->EnabledLocalePacks(false);
         $locales = array();
         foreach ($localePacks as $locale) {
             if (isset(static::$overrides[$locale]['Name'])) {
                 $locales[$locale] = static::$overrides[$locale]['Name'];
             } else {
                 $locales[$locale] = ucwords(Locale::getDisplayName($locale, $locale));
             }
         }
         $defaultName = Locale::getDisplayName($defaultLocale, $defaultLocale);
     } else {
         $locales = $localeModel->EnabledLocalePacks(true);
         $locales = array_column($locales, 'Name', 'Locale');
         $defaultName = $defaultLocale === 'en' ? 'English' : $defaultLocale;
     }
     asort($locales);
     if (!array_key_exists($defaultLocale, $locales)) {
         $locales = array_merge(array($defaultLocale => $defaultName), $locales);
     }
     return $locales;
 }
开发者ID:vanilla,项目名称:addons,代码行数:31,代码来源:class.multilingual.plugin.php

示例3: make_translations

 public static function make_translations($project, $route, $params, $context, $default_db)
 {
     $tab_links = array();
     $dm = $context->get('doctrine.odm.mongodb.document_manager');
     $dm->getConfiguration()->setDefaultDB($default_db);
     $database = $dm->createQueryBuilder('PlantnetDataBundle:Database')->field('link')->equals($project)->getQuery()->getSingleResult();
     if (!$database) {
         throw $context->createNotFoundException('Unable to find Database entity.');
     }
     $current = $database->getlanguage();
     $parent = $database->getParent();
     if ($parent) {
         $database = $parent;
     }
     $children = $database->getChildren();
     if (count($children)) {
         $params['project'] = $database->getLink();
         $tab_links[$database->getLanguage()] = array('lang' => $database->getLanguage(), 'language' => \Locale::getDisplayName($database->getLanguage(), $database->getLanguage()), 'link' => $context->get('router')->generate($route, $params, true), 'active' => $database->getLanguage() == $current ? 1 : 0);
         $tab_sub_links = array();
         foreach ($children as $child) {
             if ($child->getEnable() == true) {
                 $params['project'] = $child->getLink();
                 $tab_sub_links[$child->getLanguage()] = array('lang' => $child->getLanguage(), 'language' => \Locale::getDisplayName($child->getLanguage(), $child->getLanguage()), 'link' => $context->get('router')->generate($route, $params, true), 'active' => $child->getLanguage() == $current ? 1 : 0);
             }
         }
         if (count($tab_sub_links)) {
             ksort($tab_sub_links);
             $tab_links = array_merge($tab_links, $tab_sub_links);
         } else {
             $tab_links = array();
         }
     }
     return $tab_links;
 }
开发者ID:plantnet,项目名称:plantnet-publish,代码行数:34,代码来源:ControllerHelp.php

示例4: attachment_fields_to_edit

 /**
  * A filter matching the same name to add additional information
  * about an attachment if it is a VTT or video.
  *
  * @param array   $form_fields An array containing information about
  * the supplied attachment to display in the media library.
  * @param WP_Post $post        Attachment post being viewed from the
  * media library.
  * @return array Updated $form_fields if the attachment is a VTT or
  * video.
  * @since 1.1.0
  * @uses $webvtt
  * @see attachment_fields_to_edit()
  */
 function attachment_fields_to_edit($form_fields, $post)
 {
     global $webvtt;
     $t = $post->post_mime_type;
     if ('text/vtt' === $t) {
         if ($t = $webvtt->get_video_by_vtt_name($post->post_name)) {
             $t = $this->get_post_link_html($t);
         } else {
             $t = '--';
         }
         $form_fields['video'] = array('label' => __('Video'), 'input' => 'html', 'html' => $t);
     } elseif (0 === strpos($t, 'video/') && ($ts = $webvtt->get_tracks($post->post_name))) {
         $nl = strlen($post->post_name) + 1;
         static $labels, $locale;
         if (!$labels) {
             $labels = array('captions' => __('Video Captions', 'webvtt'), 'chapters' => __('Video Chapters', 'webvtt'), 'descriptions' => __('Video Descriptions', 'webvtt'), 'metadata' => __('Video Metadata', 'webvtt'), 'subtitles' => __('Video Subtitles', 'webvtt'));
             $locale = class_exists('Locale') ? get_locale() : false;
         }
         $vtts = array();
         foreach ($ts as $i) {
             $t = substr($i->post_name, $nl, -3);
             $j = substr($i->post_name, -2);
             if ($locale) {
                 $j = Locale::getDisplayName($j, $locale);
             }
             $vtts[$t][$j] = $i;
         }
         ksort($vtts);
         foreach ($vtts as $t => $js) {
             ksort($js);
             $h = '';
             foreach ($js as $j => $i) {
                 $h .= '<li>' . $this->get_post_link_html($i, $j) . '</li>';
             }
             $form_fields['video_' . $t] = array('label' => $labels[$t], 'input' => 'html', 'html' => '<ol>' . $h . '</ol>');
         }
     }
     return $form_fields;
 }
开发者ID:bobbywalters,项目名称:webvtt,代码行数:53,代码来源:class-webvtt-admin.php

示例5: getLanguageDescription

 static function getLanguageDescription($lang)
 {
     global $thisstaff, $thisclient;
     $langs = self::availableLanguages();
     $lang = strtolower($lang);
     if (isset($langs[$lang])) {
         $info =& $langs[$lang];
         if (!isset($info['desc'])) {
             if (extension_loaded('intl')) {
                 $lang = self::getCurrentLanguage();
                 list($simple_lang, ) = explode('_', $lang);
                 $info['desc'] = sprintf("%s%s", Locale::getDisplayName($info['code'], $info['code']), strpos($simple_lang, $info['lang']) === false ? sprintf(' (%s)', Locale::getDisplayName($info['code'], $lang)) : '');
             } else {
                 $info['desc'] = sprintf("%s%s (%s)", $info['nativeName'], $info['locale'] ? sprintf(' - %s', $info['locale']) : '', $info['name']);
             }
         }
         return $info['desc'];
     } else {
         return $lang;
     }
 }
开发者ID:KingsleyGU,项目名称:osticket,代码行数:21,代码来源:class.i18n.php

示例6: getLanguageName

 /**
  * Get the corresponding language name for a locale.
  * If the given locale contains a region code the name of that region will be appended in parentheses.
  *
  * @param string $locale Locale to be used with {@link http://php.net/manual/locale.getdisplayname.php}.
  *
  * @return string
  */
 public function getLanguageName($locale)
 {
     if (empty($locale)) {
         return null;
     }
     $localeToUse = $this->showForeignLanguageNames ? $locale : $this->getLocale();
     $languageName = \Locale::getDisplayName($locale, $localeToUse);
     if ($this->showFirstUppercase) {
         if (!extension_loaded('mbstring')) {
             throw new \RuntimeException('PHP extension "mbstring" is not loaded. Either load it or disable the "showFirstUppercase" option.');
         }
         $encoding = mb_detect_encoding($languageName);
         $languageName = mb_strtoupper(mb_substr($languageName, 0, 1, $encoding), $encoding) . mb_substr($languageName, 1, mb_strlen($languageName, $encoding), $encoding);
     }
     return $languageName;
 }
开发者ID:rdohms,项目名称:LocaleBundle,代码行数:24,代码来源:ChangeLanguageExtension.php

示例7: getLocaleLabel

 /**
  * Returns the label of a locale in the specified language
  *
  * @param string $code        the code of the locale to translate
  * @param string $translateIn the locale in which the label should be translated (if null, user locale will be used)
  *
  * @return string
  */
 public function getLocaleLabel($code, $translateIn = null)
 {
     $translateIn = $translateIn ?: $this->getCurrentLocaleCode();
     return \Locale::getDisplayName($code, $translateIn);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:13,代码来源:LocaleHelper.php

示例8: init

 /**
  *
  *
  * @param string $Path
  * @param Gdn_Controller $Controller
  */
 public function init($Path, $Controller)
 {
     $Smarty = $this->smarty();
     // Get a friendly name for the controller.
     $ControllerName = get_class($Controller);
     if (StringEndsWith($ControllerName, 'Controller', true)) {
         $ControllerName = substr($ControllerName, 0, -10);
     }
     // Get an ID for the body.
     $BodyIdentifier = strtolower($Controller->ApplicationFolder . '_' . $ControllerName . '_' . Gdn_Format::alphaNumeric(strtolower($Controller->RequestMethod)));
     $Smarty->assign('BodyID', htmlspecialchars($BodyIdentifier));
     //$Smarty->assign('Config', Gdn::Config());
     // Assign some information about the user.
     $Session = Gdn::session();
     if ($Session->isValid()) {
         $User = array('Name' => htmlspecialchars($Session->User->Name), 'Photo' => '', 'CountNotifications' => (int) val('CountNotifications', $Session->User, 0), 'CountUnreadConversations' => (int) val('CountUnreadConversations', $Session->User, 0), 'SignedIn' => true);
         $Photo = $Session->User->Photo;
         if ($Photo) {
             if (!isUrl($Photo)) {
                 $Photo = Gdn_Upload::url(changeBasename($Photo, 'n%s'));
             }
         } else {
             $Photo = UserModel::getDefaultAvatarUrl($Session->User);
         }
         $User['Photo'] = $Photo;
     } else {
         $User = false;
         /*array(
           'Name' => '',
           'CountNotifications' => 0,
           'SignedIn' => FALSE);*/
     }
     $Smarty->assign('User', $User);
     // Make sure that any datasets use arrays instead of objects.
     foreach ($Controller->Data as $Key => $Value) {
         if ($Value instanceof Gdn_DataSet) {
             $Controller->Data[$Key] = $Value->resultArray();
         } elseif ($Value instanceof stdClass) {
             $Controller->Data[$Key] = (array) $Value;
         }
     }
     $BodyClass = val('CssClass', $Controller->Data, '', true);
     $Sections = Gdn_Theme::section(null, 'get');
     if (is_array($Sections)) {
         foreach ($Sections as $Section) {
             $BodyClass .= ' Section-' . $Section;
         }
     }
     $Controller->Data['BodyClass'] = $BodyClass;
     // Set the current locale for themes to take advantage of.
     $Locale = Gdn::locale()->Locale;
     $CurrentLocale = array('Key' => $Locale, 'Lang' => str_replace('_', '-', Gdn::locale()->language(true)));
     if (class_exists('Locale')) {
         $CurrentLocale['Language'] = Locale::getPrimaryLanguage($Locale);
         $CurrentLocale['Region'] = Locale::getRegion($Locale);
         $CurrentLocale['DisplayName'] = Locale::getDisplayName($Locale, $Locale);
         $CurrentLocale['DisplayLanguage'] = Locale::getDisplayLanguage($Locale, $Locale);
         $CurrentLocale['DisplayRegion'] = Locale::getDisplayRegion($Locale, $Locale);
     }
     $Smarty->assign('CurrentLocale', $CurrentLocale);
     $Smarty->assign('Assets', (array) $Controller->Assets);
     // 2016-07-07 Linc: Request used to return blank for homepage.
     // Now it returns defaultcontroller. This restores BC behavior.
     $isHomepage = val('isHomepage', $Controller->Data);
     $Path = $isHomepage ? "" : Gdn::request()->path();
     $Smarty->assign('Path', $Path);
     $Smarty->assign('Homepage', $isHomepage);
     // true/false
     // Assign the controller data last so the controllers override any default data.
     $Smarty->assign($Controller->Data);
     $security = new SmartySecurityVanilla($Smarty);
     $security->php_handling = Smarty::PHP_REMOVE;
     $security->allow_constants = false;
     $security->allow_super_globals = false;
     $security->streams = null;
     $security->setPhpFunctions(array_merge($security->php_functions, ['array', 'category', 'checkPermission', 'inSection', 'inCategory', 'ismobile', 'multiCheckPermission', 'getValue', 'setValue', 'url', 'useragenttype']));
     $security->php_modifiers = array_merge($security->php_functions, array('sprintf'));
     $Smarty->enableSecurity($security);
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:85,代码来源:class.smarty.php

示例9: getDisplayName

 /**
  * Returns a name for the locale that is appropriate for display to the user.
  *
  * @param Locale|null $inLocale
  *
  * @return string
  */
 public function getDisplayName(Locale $inLocale = null)
 {
     return \Locale::getDisplayName($this->locale, $inLocale ? $inLocale->locale : null);
 }
开发者ID:brick,项目名称:brick,代码行数:11,代码来源:Locale.php

示例10: createFromLocale

 /**
  * @param Locale $locale
  * @param string $inLocale
  *
  * @return DisplayLocale
  */
 public static function createFromLocale(Locale $locale, $inLocale = null)
 {
     $name = $inLocale ? \Locale::getDisplayName((string) $locale, $inLocale) : \Locale::getDisplayName((string) $locale);
     return new self($locale, $name);
 }
开发者ID:andreaswarnaar,项目名称:openl10n,代码行数:11,代码来源:DisplayLocale.php

示例11: dispName

 /**
  * Returns the name of a locale after localizing it in the default or some other locale.
  *
  * @param  CULocale $inLocale **OPTIONAL. Default is** *the application's default locale*. The locale in which the
  * name is to be localized.
  *
  * @return CUStringObject The locale's localized name.
  */
 public function dispName(CULocale $inLocale = null)
 {
     $strInLocale = isset($inLocale) ? $inLocale->m_name : self::defaultLocaleName();
     return Locale::getDisplayName($this->m_name, $strInLocale);
 }
开发者ID:nunodotferreira,项目名称:Phred,代码行数:13,代码来源:CULocale.php

示例12: languageName


//.........这里部分代码省略.........
         case 'fi':
             return 'suomi';
         case 'fo':
             return 'føroyskt';
         case 'fr':
             return 'français';
         case 'fr-CA':
             return 'français canadien';
         case 'gl':
             return 'galego';
         case 'haw':
             return 'ʻŌlelo Hawaiʻi';
         case 'he':
             return 'עברית';
         case 'hr':
             return 'hrvatski';
         case 'hu':
             return 'magyar';
         case 'id':
             return 'Bahasa Indonesia';
         case 'is':
             return 'íslenska';
         case 'it':
             return 'italiano';
         case 'ja':
             return '日本語';
         case 'ka':
             return 'ქართული';
         case 'ko':
             return '한국어';
         case 'lt':
             return 'lietuvių';
         case 'lv':
             return 'latviešu';
         case 'mi':
             return 'Māori';
         case 'mr':
             return 'मराठी';
         case 'ms':
             return 'Bahasa Melayu';
         case 'nb':
             return 'norsk bokmål';
         case 'ne':
             return 'नेपाली';
         case 'nl':
             return 'Nederlands';
         case 'nn':
             return 'nynorsk';
         case 'oc':
             return 'occitan';
         case 'pl':
             return 'polski';
         case 'pt':
             return 'português';
         case 'pt-BR':
             return 'português do Brasil';
         case 'ro':
             return 'română';
         case 'ru':
             return 'русский';
         case 'sk':
             return 'slovenčina';
         case 'sl':
             return 'slovenščina';
         case 'sr':
             return 'Српски';
         case 'sr-Latn':
             return 'srpski';
         case 'sv':
             return 'svenska';
         case 'ta':
             return 'தமிழ்';
         case 'tr':
             return 'Türkçe';
         case 'tt':
             return 'Татар';
         case 'uk':
             return 'українська';
         case 'vi':
             return 'Tiếng Việt';
         case 'yi':
             return 'ייִדיש';
         case 'zh':
             return '中文';
         case 'zh-CN':
             return '简体中文';
             // Simplified Chinese
         // Simplified Chinese
         case 'zh-TW':
             return '繁體中文';
             // Traditional Chinese
         // Traditional Chinese
         default:
             // Use the PHP/intl library, if it exists
             if (class_exists('\\Locale')) {
                 return Locale::getDisplayName($language, $language);
             }
             return $language;
     }
 }
开发者ID:sadr110,项目名称:webtrees,代码行数:101,代码来源:I18N.php

示例13: getLocaleDisplayName

 /**
  * {@inheritdoc}
  */
 public function getLocaleDisplayName($locale)
 {
     return \Locale::getDisplayName($locale);
 }
开发者ID:silvestra,项目名称:locale,代码行数:7,代码来源:LocaleTemplatingHelper.php

示例14: getDisplayName

 /**
  * Returns an appropriately localized display name for the locale
  *
  * @param  string $inLocale Optional format locale
  * @return string           Name of the locale in the format appropriate for $inLocale
  */
 public function getDisplayName($inLocale = '')
 {
     if (!$inLocale) {
         $inLocale = $this->getLocale();
     }
     return IntlLocale::getDisplayName($this->getLocale(), $inLocale);
 }
开发者ID:ledgr,项目名称:localefacade,代码行数:13,代码来源:LocaleFacade.php

示例15: __toString

 public function __toString()
 {
     return Language::getDisplayName($this->code);
 }
开发者ID:Strontium-90,项目名称:Sylius,代码行数:4,代码来源:Locale.php


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