本文整理汇总了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];
}
}
示例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 '';
}
示例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');
}
示例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;
}
示例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";
}
}
}
示例6: testGetDisplayCountries
public function testGetDisplayCountries()
{
$countries = Locale::getDisplayCountries('en');
$this->assertEquals('Brazil', $countries['BR']);
}
示例7: getDefaultOptions
/**
* {@inheritdoc}
*/
public function getDefaultOptions(array $options)
{
return array('choices' => Locale::getDisplayCountries(\Locale::getDefault()));
}
示例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;
}
示例9: configure
protected function configure()
{
$this->addOption('choices', Locale::getDisplayCountries(\Locale::getDefault()));
parent::configure();
}
示例10: setDefaultOptions
/**
* {@inheritdoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array('choices' => Locale::getDisplayCountries(\Locale::getDefault())));
}
示例11: testGetDisplayCountriesForSwitzerland
public function testGetDisplayCountriesForSwitzerland()
{
IntlTestHelper::requireFullIntl($this);
$countries = Locale::getDisplayCountries('de_CH');
$this->assertEquals('Schweiz', $countries['CH']);
}
示例12: country
/**
* @param $key
* @return mixed
*/
public function country($key)
{
$countries = Locale::getDisplayCountries($this->app['locale']);
return $countries[$key];
}
示例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;
}
示例14: getCountries
/**
* {@inheritdoc}
*/
public function getCountries($language)
{
return $this->locale->getDisplayCountries($language);
}
示例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());
}