當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。