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


PHP sfCultureInfo::getCountries方法代码示例

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


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

示例1: format_country

function format_country($country_iso, $culture = null)
{
    $c = sfCultureInfo::getInstance($culture === null ? sfContext::getInstance()->getUser()->getCulture() : $culture);
    $countries = $c->getCountries();
    if (!isset($countries[$country_iso])) {
        $c = new sfCultureInfo(sfConfig::get('sf_default_culture'));
        $countries = $c->getCountries();
    }
    return isset($countries[$country_iso]) ? $countries[$country_iso] : $country_iso;
}
开发者ID:nurfiantara,项目名称:ehri-ica-atom,代码行数:10,代码来源:I18NHelper.php

示例2: setCountriesFromCultureInfo

 /**
  * Set the country list via the sfCultureInfo system.
  * @return void
  */
 protected function setCountriesFromCultureInfo()
 {
     $c = new sfCultureInfo(sfContext::getInstance()->getUser()->getCulture());
     $countries = $c->getCountries();
     foreach ($countries as $key => $value) {
         if (is_int($key)) {
             unset($countries[$key]);
         }
     }
     unset($countries['ZZ']);
     $countries = array('' => '--') + $countries;
     $this->setCountries($countries);
 }
开发者ID:pierswarmers,项目名称:rtCorePlugin,代码行数:17,代码来源:rtWidgetFormSelectCountry.class.php

示例3: configure

 /**
  * Configures the current validator.
  *
  * Available options:
  *
  *  * culture:   The culture to use for internationalized strings (required)
  *  * countries: An array of country codes to use (ISO 3166)
  *
  * @param array $options   An array of options
  * @param array $messages  An array of error messages
  *
  * @see sfValidatorChoice
  */
 protected function configure($options = array(), $messages = array())
 {
     parent::configure($options, $messages);
     $this->addRequiredOption('culture');
     $this->addOption('countries');
     // populate choices with all countries
     $culture = isset($options['culture']) ? $options['culture'] : 'en';
     $cultureInfo = new sfCultureInfo($culture);
     $countries = array_keys($cultureInfo->getCountries());
     // restrict countries to a sub-set
     if (isset($options['countries'])) {
         if ($problems = array_diff($options['countries'], $countries)) {
             throw new InvalidArgumentException(sprintf('The following countries do not exist: %s.', implode(', ', $problems)));
         }
         $countries = $options['countries'];
     }
     sort($countries);
     $this->setOption('choices', $countries);
 }
开发者ID:ajith24,项目名称:ajithworld,代码行数:32,代码来源:sfValidatorI18nChoiceCountry.class.php

示例4: format_country

function format_country($country_iso, $culture = null)
{
    $c = new sfCultureInfo($culture === null ? sfContext::getInstance()->getUser()->getCulture() : $culture);
    $countries = $c->getCountries();
    return isset($countries[$country_iso]) ? $countries[$country_iso] : '';
}
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:6,代码来源:I18NHelper.php

示例5: select_country_tag

/**
 * Returns a <select> tag populated with all the countries in the world.
 *
 * The select_country_tag builds off the traditional select_tag function, and is conveniently populated with
 * all the countries in the world (sorted alphabetically). Each option in the list has a two-character country
 * code for its value and the country's name as its display title.  The country data is retrieved via the sfCultureInfo
 * class, which stores a wide variety of i18n and i10n settings for various countries and cultures throughout the world.
 * Here's an example of an <option> tag generated by the select_country_tag:
 *
 * <samp>
 *  <option value="US">United States</option>
 * </samp>
 *
 * <b>Examples:</b>
 * <code>
 *  echo select_country_tag('country', 'FR');
 * </code>
 *
 * @param  string field name
 * @param  string selected field value (two-character country code)
 * @param  array  additional HTML compliant <select> tag parameters
 * @return string <select> tag populated with all the countries in the world.
 * @see select_tag, options_for_select, sfCultureInfo
 */
function select_country_tag($name, $selected = null, $options = array())
{
    $c = new sfCultureInfo(sfContext::getInstance()->getUser()->getCulture());
    $countries = $c->getCountries();
    if ($country_option = _get_option($options, 'countries')) {
        foreach ($countries as $key => $value) {
            if (!in_array($key, $country_option)) {
                unset($countries[$key]);
            }
        }
    }
    asort($countries);
    $option_tags = options_for_select($countries, $selected, $options);
    return select_tag($name, $option_tags, $options);
}
开发者ID:taryono,项目名称:school,代码行数:39,代码来源:FormHelper.php

示例6: getCountry

 public static function getCountry($iso, $culture)
 {
     $c = new sfCultureInfo($culture);
     $countries = $c->getCountries();
     return array_key_exists($iso, $countries) ? $countries[$iso] : '';
 }
开发者ID:DBezemer,项目名称:server,代码行数:6,代码来源:sfI18N.class.php

示例7:

$languages_en = $c_en->getLanguages();
$languages_fr = $c_fr->getLanguages();
$t->is($languages_en['fr'], 'French', '->getLanguages() returns a list of languages in the language of the localized version');
$t->is($languages_fr['fr'], 'français', '->getLanguages() returns a list of languages in the language of the localized version');
$t->is($languages_en, $c_en->Languages, '->getLanguages() is equivalent to ->Languages');
// ->getCurrencies()
$t->diag('->getCurrencies()');
$currencies_en = $c_en->getCurrencies();
$currencies_fr = $c_fr->getCurrencies();
$t->is($currencies_en['EUR'][1], 'Euro', '->getCurrencies() returns a list of currencies in the language of the localized version');
$t->is($currencies_fr['EUR'][1], 'euro', '->getCurrencies() returns a list of currencies in the language of the localized version');
$t->is($currencies_en, $c_en->Currencies, '->getCurrencies() is equivalent to ->Currencies');
// ->getCountries()
$t->diag('->getCountries()');
$countries_en = $c_en->getCountries();
$countries_fr = $c_fr->getCountries();
$t->is($countries_en['ES'], 'Spain', '->getCountries() returns a list of countries in the language of the localized version');
$t->is($countries_fr['ES'], 'Espagne', '->getCountries() returns a list of countries in the language of the localized version');
$t->is($countries_en, $c_en->Countries, '->getCountries() is equivalent to ->Countries');
// ->getScripts()
$t->diag('->getScripts()');
$scripts_en = $c_en->getScripts();
$scripts_fr = $c_fr->getScripts();
$t->is($scripts_en['Arab'], 'Arabic', '->getScripts() returns a list of scripts in the language of the localized version');
$t->is($scripts_fr['Arab'], 'arabe', '->getScripts() returns a list of scripts in the language of the localized version');
$t->is($scripts_en, $c_en->Scripts, '->getScripts() is equivalent to ->Scripts');
// ->getTimeZones()
$t->diag('->getTimeZones()');
$time_zones_en = $c_en->getTimeZones();
$time_zones_fr = $c_fr->getTimeZones();
$t->is($time_zones_en[1][0], 'America/Los_Angeles', '->getTimeZones() returns a list of time zones in the language of the localized version');
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:31,代码来源:sfCultureInfoTest.php

示例8: getCountry

 /**
  * Gets a country name.
  *
  * @param  string $iso      The ISO code
  * @param  string $culture  The culture for the translation
  *
  * @return string The country name
  */
 public function getCountry($iso, $culture = null)
 {
     $c = new sfCultureInfo(is_null($culture) ? $this->culture : $culture);
     $countries = $c->getCountries();
     return array_key_exists($iso, $countries) ? $countries[$iso] : '';
 }
开发者ID:ajith24,项目名称:ajithworld,代码行数:14,代码来源:sfI18N.class.php


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