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


PHP Intl::getLanguageBundle方法代码示例

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


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

示例1: getLanguageName

 private function getLanguageName($locale = null)
 {
     if (!$locale) {
         $locale = $this->getCurrentLocale();
     }
     return Intl::getLanguageBundle()->getLanguageName($locale, null, $this->getCurrentLocale());
 }
开发者ID:kbedn,项目名称:admin-bundle,代码行数:7,代码来源:LocaleMenuListener.php

示例2: guard

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

示例3: buildForm

 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $intlBundle = Intl::getLanguageBundle();
     $builder->add('locale', ChoiceType::class, ['choices' => $options['lang_code'], 'choices_as_values' => true, 'choice_label' => function ($lang) use($intlBundle) {
         return $intlBundle->getLanguageName($lang);
     }]);
 }
开发者ID:4devs,项目名称:locale-bridge,代码行数:10,代码来源:ChoiceLocaleType.php

示例4: loadChoiceList

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

示例5: indexAction

 public function indexAction(Request $request)
 {
     $searchForm = $this->createForm(new MainSearch());
     $searchForm->handleRequest($request);
     if ($searchForm->isValid()) {
         $userAgent = $request->headers->get('User-Agent');
         $clientIp = $request->getClientIp();
         $preferredLanguage = $request->getPreferredLanguage();
         $acceptedLanguages = $request->getLanguages();
         $languageName = Intl::getLanguageBundle()->getLanguageName($preferredLanguage);
         $data = $searchForm->getData();
         $searchRecord = new Searches();
         $searchRecord->setSearchDate(new DateTime());
         $searchRecord->setClientIpAddress($clientIp);
         $searchRecord->setAcceptedLanguages($acceptedLanguages);
         $searchRecord->setPreferredLanguage($languageName);
         $searchRecord->setUserAgent($userAgent);
         $searchRecord->setSearchText($data['search_element_text']);
         $searchRecord->setSerializedData($data);
         $em = $this->get('doctrine')->getManager();
         $em->persist($searchRecord);
         $em->flush();
         //redirect off to google
         $queryParams = array('q' => $data['search_element_text']);
         return $this->redirect(sprintf("%s#%s&tbs=qdr:y", self::GOOGLE_URL, http_build_query($queryParams)));
     } else {
         //get last 10 searches
         $lastTenSearches = $this->getDoctrine()->getRepository('YeargleCoreBundle:Searches')->getLastTenSearches();
         if (!$lastTenSearches) {
             //
             $lastTenSearches = array();
         }
         return $this->render('YeargleCoreBundle:Default:index.html.twig', array('searchForm' => $searchForm->createView(), 'lastTenSearches' => $lastTenSearches));
     }
 }
开发者ID:stuartwilsondev,项目名称:yeargle,代码行数:35,代码来源:DefaultController.php

示例6: configureOptions

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

示例7: getDisplayLanguages

 /**
  * Returns the language names for a locale.
  *
  * @param string $locale The locale to use for the language names
  *
  * @return array The language names with their codes as keys
  *
  * @throws \RuntimeException When the resource bundles cannot be loaded
  */
 public static function getDisplayLanguages($locale)
 {
     if (!isset(self::$languages[$locale])) {
         self::$languages[$locale] = Intl::getLanguageBundle()->getLanguageNames($locale);
     }
     return self::$languages[$locale];
 }
开发者ID:RuntyCybin,项目名称:csymfony,代码行数:16,代码来源:Locale.php

示例8: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $textWriter = new TextBundleWriter();
     $textWriter->write(CACHE_PATH . 'intl/text_bundle', 'en', ['data' => ['Ok']]);
     $textWriter->write(CACHE_PATH . 'intl/text_bundle', 'ru', ['data' => ['Хорошо']]);
     $phpWriter = new PhpBundleWriter();
     $phpWriter->write(CACHE_PATH . 'intl/php_bundle', 'en', ['data' => 'php bundle: Ok', 'nested' => ['message' => 'Hi!']]);
     $phpWriter = new PhpBundleWriter();
     $phpWriter->write(CACHE_PATH . 'intl/php_bundle', 'ru', ['data' => 'php bundle: Хорошо', 'nested' => ['message' => 'Привет!']]);
     $compiler = new GenrbCompiler();
     $compiler->compile(CACHE_PATH . 'intl/text_bundle', CACHE_PATH . 'intl/compiled');
     $phpReader = new PhpBundleReader();
     $data = $phpReader->read(CACHE_PATH . 'intl/php_bundle', 'en');
     $output->writeln($data['data']);
     $data = $phpReader->read(CACHE_PATH . 'intl/php_bundle', 'ru');
     $output->writeln($data['data']);
     $reader = new BundleEntryReader($phpReader);
     $data = $reader->readEntry(CACHE_PATH . 'intl/php_bundle', 'ru', ['nested', 'message']);
     $output->writeln($data);
     $language = Intl::getLanguageBundle()->getLanguageName('ru', 'RU', 'en');
     $output->writeln($language);
     $language = Intl::getLanguageBundle()->getLanguageName('ru', 'RU', 'de');
     $output->writeln($language);
     $language = Intl::getLanguageBundle()->getLanguageName('ru', 'RU', 'ru');
     $output->writeln($language);
     $currencyName = Intl::getCurrencyBundle()->getCurrencyName('RUB', 'en');
     $output->writeln($currencyName);
     $currencyName = Intl::getCurrencyBundle()->getCurrencySymbol('USD', 'en');
     $output->writeln($currencyName);
     $output->writeln('<comment>Ok</comment>');
 }
开发者ID:GrizliK1988,项目名称:symfony-certification-prepare-project,代码行数:31,代码来源:IntlTestCommand.php

示例9: __construct

 /**
  * Constructor
  */
 public function __construct(ProfileService $profileService, DocumentManager $documentManager, TranslatorInterface $translator)
 {
     $this->dm = $documentManager;
     $this->languages = Intl::getLanguageBundle()->getLanguageNames();
     $this->profileService = $profileService;
     $this->translator = $translator;
 }
开发者ID:bmartinezteltek,项目名称:PuMuKIT2,代码行数:10,代码来源:PumukitAdminExtension.php

示例10: validate

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

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

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

        $value = (string) $value;
        $languages = Intl::getLanguageBundle()->getLanguageNames();

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

示例11: __construct

 /**
  * @param GenderizeClient $genderizeClient
  */
 public function __construct(GenderizeClient $genderizeClient = null)
 {
     if ($genderizeClient) {
         $this->genderizeClient = $genderizeClient;
     } else {
         // create default client
         $this->genderizeClient = new GenderizeClient('https://api.genderize.io/');
     }
     $this->validCountries = Intl::getRegionBundle()->getCountryNames();
     $this->validLanguages = Intl::getLanguageBundle()->getLanguageNames();
 }
开发者ID:javihgil,项目名称:genderize-io-client,代码行数:14,代码来源:Genderizer.php

示例12: validate

 /**
  * {@inheritdoc}
  */
 public function validate($value, Constraint $constraint)
 {
     if (null === $value || '' === $value) {
         return;
     }
     if (!is_scalar($value) && !(is_object($value) && method_exists($value, '__toString'))) {
         throw new UnexpectedTypeException($value, 'string');
     }
     $value = (string) $value;
     $languages = Intl::getLanguageBundle()->getLanguageNames();
     if (!isset($languages[$value])) {
         $this->context->addViolation($constraint->message, array('{{ value }}' => $value));
     }
 }
开发者ID:gr-thao,项目名称:jobeet,代码行数:17,代码来源:LanguageValidator.php

示例13: retrieveLanguage

 private function retrieveLanguage($geantFeedObject)
 {
     if (!isset($geantFeedObject['expressions']['language'])) {
         throw new FeedSyncException(sprintf('There is no language (expressions.language) on feed with ID: %s', $geantFeedObject['identifier']));
     }
     $lang = $geantFeedObject['expressions']['language'];
     $lang = substr($lang, -2, 2);
     $lang = strtolower($lang);
     $languageNames = Intl::getLanguageBundle()->getLanguageNames();
     if (!array_key_exists($lang, $languageNames)) {
         throw new FeedSyncException(sprintf('The feed with ID: %s has a language format that is not recognized: %s', $geantFeedObject['identifier'], $geantFeedObject['expressions']['language']));
     }
     return $lang;
 }
开发者ID:vogias,项目名称:PuMuKIT2-geant-bundle,代码行数:14,代码来源:FeedProcesserService.php

示例14: getLanguageNames

 public static function getLanguageNames($customLanguages, $translator)
 {
     $languageNames = Intl::getLanguageBundle()->getLanguageNames();
     if ($customLanguages) {
         $choices = array();
         foreach ($customLanguages as $aux) {
             $code = strtolower($aux);
             $choices[$code] = isset($languageNames[$code]) ? $languageNames[$code] : (isset(self::$addonLanguages[$code]) ? $translator->trans(self::$addonLanguages[$code]) : $code);
         }
     } else {
         $choices = $languageNames;
     }
     return $choices;
 }
开发者ID:bmartinezteltek,项目名称:PuMuKIT2,代码行数:14,代码来源:CustomLanguageType.php

示例15: retrieveInterfaceLanguages

 private function retrieveInterfaceLanguages()
 {
     //Setting the default locale to english
     Locale::setDefault('en');
     $languages = [];
     //We want all the names of languages translated in all supported languages
     $source_languages = app('config')->get('app.supported_locales');
     if (!empty($source_languages)) {
         $target_languages = $source_languages;
         foreach ($source_languages as $language) {
             foreach ($target_languages as $targetLanguage) {
                 $languages[$language][$targetLanguage] = ucfirst(Intl::getLanguageBundle()->getLanguageName($targetLanguage, null, $language));
             }
         }
     }
     return $languages;
 }
开发者ID:linguisticteam,项目名称:laravel-boilerplate,代码行数:17,代码来源:BackendProvider.php


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