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


PHP Locale::getDisplayLanguage方法代码示例

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


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

示例1: _getOptionLocales

 /**
  * Get options array for locale dropdown
  *
  * @param   bool $translatedName translation flag
  * @return  array
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  */
 protected function _getOptionLocales($translatedName = false)
 {
     $currentLocale = $this->localeResolver->getLocale();
     $locales = \ResourceBundle::getLocales('') ?: [];
     $languages = (new LanguageBundle())->get($currentLocale)['Languages'];
     $countries = (new RegionBundle())->get($currentLocale)['Countries'];
     $options = [];
     $allowedLocales = $this->_config->getAllowedLocales();
     foreach ($locales as $locale) {
         if (!in_array($locale, $allowedLocales)) {
             continue;
         }
         $language = \Locale::getPrimaryLanguage($locale);
         $country = \Locale::getRegion($locale);
         if (!$languages[$language] || !$countries[$country]) {
             continue;
         }
         if ($translatedName) {
             $label = ucwords(\Locale::getDisplayLanguage($locale, $locale)) . ' (' . \Locale::getDisplayRegion($locale, $locale) . ') / ' . $languages[$language] . ' (' . $countries[$country] . ')';
         } else {
             $label = $languages[$language] . ' (' . $countries[$country] . ')';
         }
         $options[] = ['value' => $locale, 'label' => $label];
     }
     return $this->_sortOptionArray($options);
 }
开发者ID:vasiljok,项目名称:magento2,代码行数:33,代码来源:TranslatedLists.php

示例2: execute

 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $pages = $this->em->getAllSortBy('updatedAt');
     $draftPageCount = 0;
     $reviewPageCount = 0;
     $publishedPageCount = 0;
     $reviewPages = array();
     $draftPages = array();
     foreach ($pages as $page) {
         /** @var \Networking\InitCmsBundle\Model\PageInterface $page */
         if ($page->hasPublishedVersion()) {
             $publishedPageCount++;
         }
         if ($page->isReview()) {
             $reviewPageCount++;
             $draftPageCount++;
             $reviewPages[\Locale::getDisplayLanguage($page->getLocale())][] = $page;
         }
         if ($page->isDraft()) {
             $draftPageCount++;
             $draftPages[\Locale::getDisplayLanguage($page->getLocale())][] = $page;
         }
     }
     return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'draft_pages' => $draftPageCount, 'review_pages' => $reviewPageCount, 'published_pages' => $publishedPageCount, 'pages' => $pages, 'reviewPages' => $reviewPages, 'draftPages' => $draftPages), $response);
 }
开发者ID:lzdv,项目名称:init-cms-bundle,代码行数:28,代码来源:PagesBlockService.php

示例3: __construct

 public function __construct($em = false, $lang = 'de')
 {
     $this->em = $em;
     // we want to ignore the name passed
     parent::__construct('user');
     $this->setAttribute('method', 'post');
     $this->add(array('type' => 'Zend\\Form\\Element\\Hidden', 'name' => 'id'));
     $this->setHydrator(new DoctrineHydrator($em))->setObject(new User());
     $this->add(array('name' => 'email', 'type' => 'Zend\\Form\\Element\\Text', 'options' => array('label' => _('Email'))));
     $this->add(array('name' => 'name', 'type' => 'Zend\\Form\\Element\\Text', 'options' => array('label' => _('Full name'))));
     $this->add(array('name' => 'username', 'type' => 'Zend\\Form\\Element\\Text', 'options' => array('label' => _('Username'))));
     $this->add(array('name' => 'postalcode', 'type' => 'Zend\\Form\\Element\\Text', 'options' => array('label' => _('ZIP'))));
     $this->add(array('name' => 'locality', 'type' => 'Zend\\Form\\Element\\Text', 'options' => array('label' => _('Locality'))));
     $this->add(array('name' => 'mobilephone', 'type' => 'Zend\\Form\\Element\\Text', 'options' => array('label' => _('Mobile number'))));
     $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'locale', 'options' => array('label' => _('Language'), 'value_options' => array('de' => \Locale::getDisplayLanguage('de', 'de'), 'en' => \Locale::getDisplayLanguage('en', 'en'), 'fr' => \Locale::getDisplayLanguage('fr', 'fr'), 'it' => \Locale::getDisplayLanguage('it', 'it')))));
     $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'role', 'options' => array('label' => _('Role'), 'value_options' => array('registered' => 'Minimal', 'client' => 'Klient', 'marketing' => 'Marketing', 'receptionist' => 'Rezeption', 'salesSupport' => 'Verkaufs-Unterstützung', 'consultant' => 'Verkauf', 'editor' => 'Editor', 'admin' => 'Administrator'))));
     /*  $addressFieldset = new AddressFieldset($em, $lang);
         $this->add(array(
             'type'    => 'Zend\Form\Element\Collection',
             'name'    => 'addresses',
             'options' => array(
                 'count'           => 1, 
                 'target_element'  => $addressFieldset,
                 //'should_create_template' => true
             )
         ));*/
 }
开发者ID:omusico,项目名称:casawp,代码行数:27,代码来源:UserFieldset.php

示例4: getLocalizationOptions

 /**
  * localization options array
  *
  * @param array $opts options array
  *
  * @return array
  */
 public static function getLocalizationOptions($opts)
 {
     $locales = array();
     foreach ($opts as $opt) {
         $locales[$opt] = \Locale::getDisplayLanguage($opt);
     }
     return $locales;
 }
开发者ID:jignesh-russmediatech,项目名称:rmcdemo,代码行数:15,代码来源:RmcHelpers.php

示例5: newAction

 /**
  * New email
  *
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function newAction(Request $request)
 {
     $handler = $this->get('lexik_mailer.form.handler.email');
     $form = $handler->createForm();
     if ($handler->processForm($form, $request)) {
         return $this->redirect($this->generateUrl('lexik_mailer.email_list'));
     }
     return $this->render('LexikMailerBundle:Email:new.html.twig', array_merge(array('form' => $form->createView(), 'layout' => $this->container->getParameter('lexik_mailer.base_layout'), 'lang' => \Locale::getDisplayLanguage($handler->getLocale())), $this->getAdditionalParameters()));
 }
开发者ID:anhnt0212,项目名称:LexikMailerBundle,代码行数:15,代码来源:EmailController.php

示例6: getLangRows

 /**
  * @return Generator|array
  */
 protected function getLangRows()
 {
     foreach ($this->getLanguages() as $locale) {
         $primaryLanguage = Locale::getPrimaryLanguage($locale);
         $displayLanguage = Locale::getDisplayLanguage($locale, $primaryLanguage);
         $displayLanguage = mb_convert_case($displayLanguage, MB_CASE_TITLE, "UTF-8");
         (yield [$primaryLanguage, $displayLanguage, $locale, 10]);
     }
 }
开发者ID:lav45,项目名称:yii2-translated-behavior-demo,代码行数:12,代码来源:m151221_225031_lang.php

示例7: toOptionArray

 /**
  * Return option array
  *
  * @return array
  */
 public function toOptionArray()
 {
     $languages = [];
     foreach ($this->_helper->getLanguageCodes() as $languageCode) {
         $localeCode = $this->_helper->convertLanguageCodeToLocaleCode($languageCode);
         $translationForSpecifiedLanguage = \Locale::getDisplayLanguage($localeCode, $localeCode);
         $translationForDefaultLanguage = \Locale::getDisplayLanguage($localeCode);
         $label = sprintf('%s / %s (%s)', $this->_uppercaseFilter->filter($translationForSpecifiedLanguage), $translationForDefaultLanguage, $languageCode);
         $languages[] = ['value' => $languageCode, 'label' => $label];
     }
     return $languages;
 }
开发者ID:kidaa30,项目名称:magento2-platformsh,代码行数:17,代码来源:Language.php

示例8: getAvailableLanguages

 public static function getAvailableLanguages()
 {
     $langs = array();
     //TODO make directory not absolute path?
     $lang_codes = glob('/usr/share/grase/locale/??', GLOB_ONLYDIR);
     foreach ($lang_codes as $code) {
         $lang['display'] = \Locale::getDisplayLanguage(basename($code), 'en');
         $lang['code'] = basename($code);
         $langs[] = $lang;
     }
     return $langs;
 }
开发者ID:KuberKode,项目名称:grase-www-portal,代码行数:12,代码来源:Locale.php

示例9: getDisplayLanguage

 /**
  * Returns detailed informations from the language table
  * If no detail is given a complete table is returned
  *
  * @param string  $locale Normalized locale
  * @param boolean $invert Invert output of the data
  * @param string|array $detail Detail to return information for
  * @return array
  */
 public static function getDisplayLanguage($locale, $invert = false, $detail = null)
 {
     if ($detail !== null) {
         return Locale::getDisplayLanguage($locale);
     } else {
         $list = ZFLocale::getLocaleList();
         foreach ($list as $key => $value) {
             $list[$key] = Locale::getDisplayLanguage($key);
         }
         if ($invert) {
             array_flip($list);
         }
         return $list;
     }
 }
开发者ID:bradley-holt,项目名称:zf2,代码行数:24,代码来源:Intl.php

示例10: setLocale

 /**
  * Set the current locale.
  * 
  * @param string $locale The locale
  * @return LocaleManager
  */
 public function setLocale($locale)
 {
     // Always use caninicalized locales
     $locale = Locale::canonicalize($locale);
     // If the given locale matches the current locale, nothing to do.
     if (strcmp($locale, $this->locale) === 0) {
         return $this;
     }
     // Set locale information
     $localeVariants = [$locale . '.UTF-8', $locale, \Locale::getDisplayLanguage($locale, 'en')];
     if (false === setlocale(LC_ALL, $localeVariants)) {
         throw new LocaleNotAvailableException(sprintf('The locale "%s" is not available on the system.', $locale));
     }
     // Store the locale
     $this->locale = Locale::canonicalize($locale);
     return $this;
 }
开发者ID:gambit-cms,项目名称:gambit-localemanager,代码行数:23,代码来源:LocaleManager.php

示例11: languagesAction

 /**
  * Render all available languages
  *
  * @param string $id the id to the content document to build translations for
  * @param array $languageUrls optional to not generate routes: list of language code to array with url, fullname and completion
  */
 public function languagesAction($id, $languageUrls = false)
 {
     if ($languageUrls === false) {
         $languageUrls = array();
         $available = $this->chooser->getDefaultLocalesOrder();
         if (count($available) < 2) {
             //nothing to choose from, don't show language chooser
             return new Response();
         }
         $content = $this->om->find(null, $id);
         foreach ($available as $lang) {
             $languageUrls[$lang]['fullname'] = \Locale::getDisplayLanguage($lang, $lang);
             $languageUrls[$lang]['url'] = $this->router->generate('', array('_locale' => $lang, 'content' => $content));
             // TODO: check for availability of this url in this lang and add to the language info.
             // we could also provide a variant that walks up the tree to link only existing languages if no fallback is desired
         }
     }
     return $this->templating->renderResponse('SymfonyCmfMultilangContentBundle:LanguageSelector:languageselector.html.twig', array('languageUrls' => $languageUrls));
 }
开发者ID:richardmiller,项目名称:symfony-cmf,代码行数:25,代码来源:LanguageSelectorController.php

示例12: execute

 /**
  * {@inheritdoc}
  */
 public function execute(BlockContextInterface $blockContext, Response $response = null)
 {
     $pages = $this->em->getAllSortBy('updatedAt', 'DESC', Query::HYDRATE_ARRAY);
     $draftPageCount = 0;
     $reviewPageCount = 0;
     $publishedPageCount = 0;
     $reviewPages = array();
     $draftPages = array();
     foreach ($pages as $page) {
         if (array_key_exists('snapshots', $page) && count($page['snapshots']) > 0) {
             $publishedPageCount++;
         }
         if ($page['status'] == PageInterface::STATUS_REVIEW) {
             $reviewPageCount++;
             $draftPageCount++;
             $reviewPages[\Locale::getDisplayLanguage($page['locale'])][] = $page;
         }
         if ($page['status'] == PageInterface::STATUS_DRAFT) {
             $draftPageCount++;
             $draftPages[\Locale::getDisplayLanguage($page['locale'])][] = $page;
         }
     }
     return $this->renderResponse($blockContext->getTemplate(), array('block' => $blockContext->getBlock(), 'draft_pages' => $draftPageCount, 'review_pages' => $reviewPageCount, 'published_pages' => $publishedPageCount, 'pages' => $pages, 'reviewPages' => $reviewPages, 'draftPages' => $draftPages), $response);
 }
开发者ID:rapemer,项目名称:init-cms-bundle,代码行数:27,代码来源:PagesBlockService.php

示例13: displayLanguage

 /**
  * Return the language name corresponding to the given ISO code
  * NB: the name is localized if the intl extension is installed, otherwise it is returned in English
  * @param string $iso
  * @return string
  */
 function displayLanguage($iso)
 {
     if (!$iso) {
         return '';
     }
     return class_exists('Locale') ? \Locale::getDisplayLanguage($iso, $this->locale()) : constant('ISO::LC_' . $iso);
 }
开发者ID:xfra35,项目名称:f3-multilang,代码行数:13,代码来源:multilang.php

示例14: displayLanguage

 /**
  * Display language
  *
  * @return string
  */
 public function displayLanguage()
 {
     return \Locale::getDisplayLanguage($this->getLang());
 }
开发者ID:anhnt0212,项目名称:LexikMailerBundle,代码行数:9,代码来源:EmailTranslation.php

示例15: getLanguageName

 /**
  * Get the language name.
  * @param string $locale Locale to be used with {@link http://php.net/manual/locale.getdisplaylanguage.php}.
  * @return string
  */
 public function getLanguageName($locale)
 {
     $localeToUse = $this->showForeignLanguageNames === true ? $locale : $this->getLocale();
     $languageName = \Locale::getDisplayLanguage($locale, $localeToUse);
     if ($this->showFirstUppercase === true) {
         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:ricychaco,项目名称:TwigExtensionsBundle,代码行数:18,代码来源:ChangeLanguageExtension.php


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