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


PHP Locale::getDisplayCountries方法代码示例

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


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

示例1: getDisplayCountry

 /**
  * Localize country name
  *
  * @param  string $code
  * @return string
  */
 public function getDisplayCountry($code)
 {
     $code = strtoupper($code);
     $countries = Locale::getDisplayCountries($this->request->getLocale());
     if (isset($countries[$code])) {
         return $countries[$code];
     }
 }
开发者ID:yoye,项目名称:localizationbundle,代码行数:14,代码来源:Localizer.php

示例2: country

 /**
  * @param $code
  * @param null $locale
  *
  * @return string
  */
 public function country($code, $locale = null)
 {
     $countries = Locale::getDisplayCountries($locale ?: $this->localeDetector->getLocale());
     if (array_key_exists($code, $countries)) {
         return $this->fixCharset($countries[$code]);
     }
     return '';
 }
开发者ID:ingeniorweb,项目名称:symfo3cv,代码行数:14,代码来源:LocaleHelper.php

示例3: testGetDisplayCountriesReturnsFullListForSubLocale

 public function testGetDisplayCountriesReturnsFullListForSubLocale()
 {
     $this->skipIfIntlExtensionIsNotLoaded();
     $countriesDe = Locale::getDisplayCountries('de');
     $countriesDeCh = Locale::getDisplayCountries('de_CH');
     $this->assertEquals(count($countriesDe), count($countriesDeCh));
     $this->assertEquals($countriesDe['BD'], 'Bangladesch');
     $this->assertEquals($countriesDeCh['BD'], 'Bangladesh');
 }
开发者ID:nicodmf,项目名称:symfony,代码行数:9,代码来源:LocaleTest.php

示例4: thereIsCountry

 /**
  * @Given /^I created country "([^""]*)"$/
  * @Given /^there is country "([^""]*)"$/
  */
 public function thereIsCountry($name, $provinces = null, $flush = true)
 {
     /* @var $country CountryInterface */
     if (null === ($country = $this->getRepository('country')->findOneBy(array('name' => $name)))) {
         $country = $this->getRepository('country')->createNew();
         $country->setName(trim($name));
         $country->setIsoName(array_search($name, Locale::getDisplayCountries(Locale::getDefault())));
         if (null !== $provinces) {
             $provinces = $provinces instanceof TableNode ? $provinces->getHash() : $provinces;
             foreach ($provinces as $provinceName) {
                 $country->addProvince($this->thereisProvince($provinceName));
             }
         }
         $manager = $this->getEntityManager();
         $manager->persist($country);
         if ($flush) {
             $manager->flush();
         }
     }
     return $country;
 }
开发者ID:bcremer,项目名称:Sylius,代码行数:25,代码来源:AddressingContext.php

示例5: addCustomProperty

 public function addCustomProperty(TransformEvent $event)
 {
     $object = $event->getObject();
     $document = $event->getDocument();
     $document->addGeoPoint('location', $object->getLat(), $object->getLng());
     if (!$object->getProvince()) {
         $locale = 'it';
         $countries = Locale::getDisplayCountries($locale);
         $country = $countries[$object->getCountry()];
         $address = $object->getAddress() . ' ' . $object->getTown() . ' ' . $country;
         try {
             $result = $this->geocode->using('google_maps')->reverse($object->getLat(), $object->getLng());
             $document->set('town', $result->getCity());
             $document->set('zipcode', $result->getZipcode());
             $document->set('province', $result->getCountyCode());
             $document->set('country', $result->getCountryCode());
             $document->set('address', $result->getStreetName() . ' ' . $result->getStreetNumber());
             $document->set('region', $result->getRegion());
         } catch (\Exception $e) {
             print $object->getId() . '::' . $e->getMessage() . "\n";
         }
     }
 }
开发者ID:arest,项目名称:metano_importer,代码行数:23,代码来源:DistributorListener.php

示例6: testGetDisplayCountries

 public function testGetDisplayCountries()
 {
     $countries = Locale::getDisplayCountries('en');
     $this->assertEquals('Brazil', $countries['BR']);
 }
开发者ID:d3ancole1995,项目名称:symfony,代码行数:5,代码来源:LocaleTest.php

示例7: getDefaultOptions

 /**
  * {@inheritdoc}
  */
 public function getDefaultOptions(array $options)
 {
     return array('choices' => Locale::getDisplayCountries(\Locale::getDefault()));
 }
开发者ID:artz20,项目名称:Tv-shows-zone,代码行数:7,代码来源:CountryType.php

示例8: countryFilter

 /**
  * Translate a country indicator to its locale full name
  * @param string $country The contry indicator
  * @param string $default The default value is the country does not exist (optionnal)
  * @return string The localized string
  */
 public static function countryFilter($country, $default = '')
 {
     $countries = Locale::getDisplayCountries(\Locale::getDefault());
     
     return array_key_exists($country, $countries) ? $countries[$country] : $default;
 }
开发者ID:rubensayshi,项目名称:BCCExtraToolsBundle,代码行数:12,代码来源:TwigExtension.php

示例9: configure

 protected function configure()
 {
     $this->addOption('choices', Locale::getDisplayCountries(\Locale::getDefault()));
     parent::configure();
 }
开发者ID:yproximite,项目名称:symfony-legacy-form,代码行数:5,代码来源:CountryField.php

示例10: setDefaultOptions

 /**
  * {@inheritdoc}
  */
 public function setDefaultOptions(OptionsResolverInterface $resolver)
 {
     $resolver->setDefaults(array('choices' => Locale::getDisplayCountries(\Locale::getDefault())));
 }
开发者ID:laubosslink,项目名称:lab,代码行数:7,代码来源:CountryType.php

示例11: testGetDisplayCountriesForSwitzerland

 public function testGetDisplayCountriesForSwitzerland()
 {
     IntlTestHelper::requireFullIntl($this);
     $countries = Locale::getDisplayCountries('de_CH');
     $this->assertEquals('Schweiz', $countries['CH']);
 }
开发者ID:BusinessCookies,项目名称:CoffeeMachineProject,代码行数:6,代码来源:LocaleTest.php

示例12: country

 /**
  * @param $key
  * @return mixed
  */
 public function country($key)
 {
     $countries = Locale::getDisplayCountries($this->app['locale']);
     return $countries[$key];
 }
开发者ID:nymo,项目名称:silex-twig-country-extension,代码行数:9,代码来源:CountryExtension.php

示例13: countryFilter

 /**
  * Translate a country indicator to its locale full name
  * Uses default system locale by default. Pass another locale string to force a different translation
  *
  * @param string $country The contry indicator
  * @param string $default The default value is the country does not exist (optionnal)
  * @param mixed $locale
  * 
  * @return string The localized string
  * @access public
  * @static
  * 
  * @author Etienne de Longeaux <etienne.delongeaux@gmail.com>
  */
 public function countryFilter($country, $default = '', $locale = null)
 {
     $locale = $locale == null ? \Locale::getDefault() : $locale;
     $countries = Locale::getDisplayCountries($locale);
     return array_key_exists($country, $countries) ? $countries[$country] : $default;
 }
开发者ID:pigroupe,项目名称:SfynxToolBundle,代码行数:20,代码来源:PiDateExtension.php

示例14: getCountries

 /**
  * {@inheritdoc}
  */
 public function getCountries($language)
 {
     return $this->locale->getDisplayCountries($language);
 }
开发者ID:fkomaralp,项目名称:country-list,代码行数:7,代码来源:Icu.php

示例15: getDisplayCountries

 /**
  * Returns the country names for locale
  *
  * @return array The country names with their codes as keys
  */
 public function getDisplayCountries()
 {
     return SymfonyLocale::getDisplayCountries($this->getLocale());
 }
开发者ID:ledgr,项目名称:localefacade,代码行数:9,代码来源:LocaleFacade.php


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