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


PHP Intl::getLocaleBundle方法代码示例

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


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

示例1: validate

    /**
     * {@inheritdoc}
     */
    public function validate($value, Constraint $constraint)
    {
        if (!$constraint instanceof Locale) {
            throw new UnexpectedTypeException($constraint, __NAMESPACE__.'\Locale');
        }

        if (null === $value || '' === $value) {
            return;
        }

        if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
            throw new UnexpectedTypeException($value, 'string');
        }

        $value = (string) $value;
        $locales = Intl::getLocaleBundle()->getLocaleNames();

        if (!isset($locales[$value])) {
            if ($this->context instanceof ExecutionContextInterface) {
                $this->context->buildViolation($constraint->message)
                    ->setParameter('{{ value }}', $this->formatValue($value))
                    ->setCode(Locale::NO_SUCH_LOCALE_ERROR)
                    ->addViolation();
            } else {
                $this->buildViolation($constraint->message)
                    ->setParameter('{{ value }}', $this->formatValue($value))
                    ->setCode(Locale::NO_SUCH_LOCALE_ERROR)
                    ->addViolation();
            }
        }
    }
开发者ID:ninvfeng,项目名称:symfony,代码行数:34,代码来源:LocaleValidator.php

示例2: getName

 /**
  * @return string
  */
 public function getName($locale = null)
 {
     $enc = 'utf-8';
     $names = Intl::getLocaleBundle()->getLocaleNames($locale ?: $this->locale);
     $str = isset($names[$this->locale]) ? $names[$this->locale] : $this->locale;
     return mb_strtoupper(mb_substr($str, 0, 1, $enc), $enc) . mb_substr($str, 1, mb_strlen($str, $enc), $enc);
 }
开发者ID:modera,项目名称:foundation,代码行数:10,代码来源:Language.php

示例3: configureOptions

 /**
  * {@inheritdoc}
  */
 public function configureOptions(OptionsResolver $resolver)
 {
     $resolver->setDefaults(array(
         'choices' => Intl::getLocaleBundle()->getLocaleNames(),
         'choice_translation_domain' => false,
     ));
 }
开发者ID:ninvfeng,项目名称:symfony,代码行数:10,代码来源:LocaleType.php

示例4: guard

 /**
  * @param mixed $value
  *
  * @throws InvalidLocaleException
  */
 protected function guard($value)
 {
     $localeName = Intl::getLocaleBundle()->getLocaleName($value);
     if (null === $localeName) {
         throw new InvalidLocaleException($value);
     }
 }
开发者ID:bruli,项目名称:php-value-objects,代码行数:12,代码来源:Locale.php

示例5: loadChoiceList

 /**
  * {@inheritdoc}
  */
 public function loadChoiceList($value = null)
 {
     if (null !== $this->choiceList) {
         return $this->choiceList;
     }
     return $this->choiceList = new ArrayChoiceList(array_flip(Intl::getLocaleBundle()->getLocaleNames()), $value);
 }
开发者ID:ayoah,项目名称:symfony,代码行数:10,代码来源:LocaleType.php

示例6: prettyLocaleName

 /**
  * Display the name of a locale by its code, like English (United States) when you provide en_US
  *
  * @param string $code
  *
  * @return string
  */
 public function prettyLocaleName($code)
 {
     if (empty($code)) {
         return '';
     }
     return Intl::getLocaleBundle()->getLocaleName($code);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:14,代码来源:LocaleExtension.php

示例7: getGlobals

 public function getGlobals()
 {
     $locales = array('current' => null, 'other' => null);
     $enabledLocales = $this->localeRepository->findBy(array('isEnabled' => true));
     $otherLocales = $enabledLocales;
     if (count($enabledLocales)) {
         /** @var Locale $locale */
         foreach ($enabledLocales as $localeKey => $locale) {
             if ($this->currentLocale == $locale->getCode()) {
                 $locales['current'] = $locale;
                 unset($otherLocales[$localeKey]);
                 break;
             }
         }
     }
     if (!count($enabledLocales) || empty($locales['current'])) {
         $defaultLocaleCode = $this->container->getParameter('locale');
         $locale = new Locale();
         $locale->setCode($defaultLocaleCode);
         $locale->setTitle(Intl::getLocaleBundle()->getLocaleName($defaultLocaleCode, $defaultLocaleCode));
         $locales['current'] = $locale;
     }
     $locales['other'] = $otherLocales;
     return array('locales' => $locales);
 }
开发者ID:orkestro,项目名称:orkestro,代码行数:25,代码来源:LocaleExtension.php

示例8: getLocales

 /**
  * @return array
  */
 public function getLocales()
 {
     $localeCodes = explode('|', $this->locales);
     foreach ($localeCodes as $localeCode) {
         $locales[] = array('code' => $localeCode, 'name' => Intl::getLocaleBundle()->getLocaleName($localeCode, $localeCode));
     }
     return $locales;
 }
开发者ID:hasstoss,项目名称:symfony-demo,代码行数:11,代码来源:LocaleExtension.php

示例9: createMenu

 /**
  * Builds frontend locale menu.
  *
  * @return ItemInterface
  */
 public function createMenu()
 {
     $menu = $this->factory->createItem('root', array('childrenAttributes' => array('class' => 'nav nav-pills')));
     foreach ($this->localeProvider->getAvailableLocales() as $locale) {
         $code = $locale->getCode();
         $menu->addChild($code, array('route' => 'sylius_locale_change', 'routeParameters' => array('locale' => $code)))->setLabel(Intl::getLocaleBundle()->getLocaleName($code));
     }
     return $menu;
 }
开发者ID:bcremer,项目名称:Sylius,代码行数:14,代码来源:LocaleMenuBuilder.php

示例10: getLocaleNames

 /**
  * {@inheritdoc}
  */
 public function getLocaleNames()
 {
     $locales = Intl::getLocaleBundle()->getLocaleNames();
     $Data = [];
     foreach ($locales as $locale => $name) {
         $Data[$locale] = sprintf('%s (%s)', $name, $locale);
     }
     return $Data;
 }
开发者ID:raizeta,项目名称:WellCommerce,代码行数:12,代码来源:LocaleRepository.php

示例11: load

 /**
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $localeSettings = $this->container->get('oro_locale.settings');
     $locale = new Locale();
     $locale->setCode(Intl::getLocaleBundle()->getLocaleName($localeSettings->getLanguage(), $localeSettings->getLocale()));
     $manager->persist($locale);
     /** @var EntityManager $manager */
     $manager->flush($locale);
     $this->addReference('default_website_locale', $locale);
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:13,代码来源:LoadLocaleData.php

示例12: getAvailableLocales

 /**
  * Should be private, used public to support PHP 5.3
  *
  * @internal
  *
  * @return array
  */
 public function getAvailableLocales()
 {
     $availableLocales = Intl::getLocaleBundle()->getLocaleNames();
     /** @var LocaleInterface[] $definedLocales */
     $definedLocales = $this->localeRepository->findAll();
     foreach ($definedLocales as $locale) {
         unset($availableLocales[$locale->getCode()]);
     }
     return $availableLocales;
 }
开发者ID:lingoda,项目名称:Sylius,代码行数:17,代码来源:LocaleType.php

示例13: beforeRender

 protected function beforeRender()
 {
     parent::beforeRender();
     $this->template->parameters = $this->context->parameters;
     $this->template->acl = $this->acl;
     $this->template->addFilter('langName', function ($locale) {
         return Intl::getLocaleBundle()->getLocaleName($locale);
     });
     $this->template->projects = $this->projectFacade->findAll();
 }
开发者ID:bazo,项目名称:translation-ui,代码行数:10,代码来源:SecuredPresenter.php

示例14: doLoad

 /**
  * {@inheritdoc}
  */
 protected function doLoad(ObjectManager $manager)
 {
     $defaultCode = $this->getContainer()->getParameter('lug.locale');
     foreach (array_keys(Intl::getLocaleBundle()->getLocaleNames()) as $code) {
         $locale = $this->getFactory()->create(['code' => $code, 'enabled' => $code === $defaultCode, 'required' => $code === $defaultCode]);
         $manager->persist($locale);
         $this->setReference('lug.locale.' . $code, $locale);
     }
     $manager->flush();
 }
开发者ID:php-lug,项目名称:lug,代码行数:13,代码来源:AbstractLocaleFixture.php

示例15: getLanguageChoices

 /**
  * @return array
  */
 protected function getLanguageChoices()
 {
     // ensure that default value is always in choice list
     $defaultValue = $this->cm->get(self::CONFIG_KEY, true);
     $availableTranslations = (array) $this->cm->get(TranslationStatusInterface::CONFIG_KEY);
     $availableTranslations = array_filter($availableTranslations, function ($languageStatus) {
         return $languageStatus === TranslationStatusInterface::STATUS_ENABLED;
     });
     $availableLanguages = array_merge(array_keys($availableTranslations), [$defaultValue]);
     $allLanguages = Intl::getLocaleBundle()->getLocaleNames('en');
     return array_intersect_key($allLanguages, array_flip($availableLanguages));
 }
开发者ID:Maksold,项目名称:platform,代码行数:15,代码来源:LanguageType.php


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