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


PHP sfCultureInfo::getLanguages方法代码示例

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


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

示例1: format_language

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

示例2: object_multiselect_language_tag

/**
 * Returns a <selectize> tag populated with all the languages in the world (or almost).
 *
 * The select_language_tag builds off the traditional select_tag function, and is conveniently populated with
 * all the languages in the world (sorted alphabetically). Each option in the list has a two or three character
 * language/culture code for its value and the language'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="en">English</option>
 * </samp>
 *
 * <b>Examples:</b>
 * <code>
 *  echo select_language_tag('language', 'de');
 * </code>
 *
 * @param  string $name     field name
 * @param  string $selected selected field values (two or three-character language/culture code)
 * @param  array  $options  additional HTML compliant <select> tag parameters
 *
 * @return string <selectize> tag populated with all the languages in the world.
 * @see select_tag, options_for_select, sfCultureInfo
 */
function object_multiselect_language_tag($name, $selected = null, $options = array())
{
    $c = new sfCultureInfo(sfContext::getInstance()->getUser()->getCulture());
    $languages = $c->getLanguages();
    if ($language_option = _get_option($options, 'languages')) {
        foreach ($languages as $key => $value) {
            if (!in_array($key, $language_option)) {
                unset($languages[$key]);
            }
        }
    }
    asort($languages);
    $option_tags = options_for_select($languages, $selected, $options);
    unset($options['include_blank'], $options['include_custom']);
    return select_tag($name, $option_tags, $options);
}
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:41,代码来源:LanguageHelper.php

示例3: configure

 /**
  * Constructor.
  *
  * Available options:
  *
  *  * culture:   The culture to use for internationalized strings (required)
  *  * languages: An array of language codes to use (ISO 639-1)
  *
  * @param array $options     An array of options
  * @param array $attributes  An array of default HTML attributes
  *
  * @see sfWidgetFormSelect
  */
 protected function configure($options = array(), $attributes = array())
 {
     parent::configure($options, $attributes);
     $this->addRequiredOption('culture');
     $this->addOption('languages');
     // populate choices with all languages
     $culture = isset($options['culture']) ? $options['culture'] : 'en';
     $cultureInfo = new sfCultureInfo($culture);
     $languages = $cultureInfo->getLanguages();
     // restrict languages to a sub-set
     if (isset($options['languages'])) {
         if ($problems = array_diff($options['languages'], array_keys($languages))) {
             throw new InvalidArgumentException(sprintf('The following languages do not exist: %s.', implode(', ', $problems)));
         }
         $languages = array_intersect_key($languages, array_flip($options['languages']));
     }
     asort($languages);
     $this->setOption('choices', $languages);
 }
开发者ID:ajith24,项目名称:ajithworld,代码行数:32,代码来源:sfWidgetFormI18nSelectLanguage.class.php

示例4: format_language

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

示例5: getDefaultLanguage

 private function getDefaultLanguage($textual = false)
 {
     $language = 'en';
     if (!$this->vocabulary) {
         $this->vocabulary = VocabularyPeer::retrieveByPk($this->getRequestParameter('id'));
     }
     if (isset($this->vocabulary)) {
         $language = $this->vocabulary->getLanguage();
     }
     if (!$textual) {
         return $language;
     } else {
         $culture = 'en';
         /** @var sfUser $user */
         $user = $this->getUser();
         if ($user) {
             $culture = $user->getCulture();
         }
         $cultureInfo = new sfCultureInfo($culture);
         $languages = $cultureInfo->getLanguages();
         return $languages[$language];
     }
 }
开发者ID:jonphipps,项目名称:Metadata-Registry,代码行数:23,代码来源:actions.class.php

示例6: function

$sfExtjs3Plugin->begin();
$sfExtjs3Plugin->end();
?>
<script type='text/javascript'>

Ext.namespace('Login');
  Login = function(){
    var loginWindow, loginForm;    
    return{
      init:function(){
        Ext.QuickTips.init();
        Ext.form.Field.prototype.msgTarget = 'side';
          
        <?php 
$culture = new sfCultureInfo(sfContext::getInstance()->getUser()->getCulture());
$languages = $culture->getLanguages(array('pt', 'en'));
$js_languages = array();
foreach ($languages as $language_code => $language_name) {
    $js_languages[] = "[" . json_encode($language_code) . ', ' . json_encode(ucfirst($language_name)) . "]";
}
$language_js = implode(',', $js_languages);
echo "var language_data = [" . $language_js . "];";
?>

        //language_data
        /* Language chooser combobox  */
        var store = new Ext.data.ArrayStore({
            fields: ['code', 'language'],
            data : language_data});

        var combo = new Ext.form.ComboBox({
开发者ID:ketheriel,项目名称:ETVA,代码行数:31,代码来源:signinSuccess.php

示例7: sfCultureInfo

// __toString()
$t->diag('__toString()');
$c = new sfCultureInfo();
$t->is($c->__toString(), 'en', '->__toString() returns the name of the culture');
try {
    $c = new sfCultureInfo('xxx');
    $t->fail('->__construct() throws an exception if the culture is not valid');
} catch (sfException $e) {
    $t->pass('->__construct() throws an exception if the culture is not valid');
}
$c_en = new sfCultureInfo();
$c_fr = new sfCultureInfo('fr');
// ->getLanguages()
$t->diag('->getLanguages()');
$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');
开发者ID:valerio-bozzolan,项目名称:openparlamento,代码行数:31,代码来源:sfCultureInfoTest.php


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