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


PHP HTTP::negotiateLanguage方法代码示例

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


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

示例1: localization_setup

function localization_setup()
{
    global $lang, $domain, $encoding, $available_locales, $preferred_lang;
    // Choose a default language based on the client's HTTP headers.
    // TODO: Replace HTTP::negotiateLanguage with something less buggy.
    // (See http://www.dracos.co.uk/web/php/HTTP/ for details.)
    $supported = $available_locales;
    $preferred_lang = HTTP::negotiateLanguage($supported, $lang);
    if ($preferred_lang) {
        $lang = $preferred_lang;
    }
    // Override the default if the user has an explicit cookie or query string.
    $force_lang = get_requested_lang();
    if ($force_lang) {
        $lang = $force_lang;
    }
    if ($available_locales[$lang]) {
        // Set the locale.
        $locale = $available_locales[$lang][0];
        setlocale(LC_ALL, $locale);
        // Find the locale directory.
        $path_parts = pathinfo(__FILE__);
        $this_dir = $path_parts["dirname"];
        bindtextdomain($domain, "{$this_dir}/../locale");
        // Set up gettext message localization.
        textdomain($domain);
        bind_textdomain_codeset($domain, $encoding);
    }
    // Tell clients to cache different languages separately.
    header("Vary: Accept-Language");
}
开发者ID:ruthmagnus,项目名称:audacity,代码行数:31,代码来源:lang.inc.php

示例2: load

 function load(k_Context $context)
 {
     require_once 'PEAR.php';
     require_once 'HTTP.php';
     if ($context->query('lang') == 'da') {
         return new DanishLanguage();
     } else {
         if ($context->query('lang') == 'fr') {
             return new FrenchLanguage();
         } else {
             if ($context->query('lang') == 'de') {
                 return new GermanLanguage();
             } else {
                 if ($context->query('lang') == 'hi') {
                     return new HindiLanguage();
                 } else {
                     if ($context->query('lang')) {
                         return new DanishLanguage();
                     }
                 }
             }
         }
     }
     $supported = array("da" => true, "en-US" => true);
     $language = HTTP::negotiateLanguage($supported);
     if (PEAR::isError($language)) {
         // fallback language in case of unable to negotiate
         return new DanishLanguage();
     }
     if ($language == 'en-US') {
         return new EnglishLanguage();
     }
     return new DanishLanguage();
 }
开发者ID:RussellDias,项目名称:konstrukt,代码行数:34,代码来源:index.php

示例3: array

/*
 * reads config file
 */
$blocks = array();
$data = array();
$conf = new Config('IniFile');
$conf->parseInput('rubbercity.ini');
$blocks = $conf->getBlocks("/");
foreach ($blocks as $block) {
    $cfg[$block] = $conf->getValues("/" . $block);
}
/*
 * Sets the language according to browser settings
 */
$langSupported = array("de" => true, "en" => true);
define("LC_LANG", HTTP::negotiateLanguage($langSupported, 'en'));
$langSelected = 'rc_' . LC_LANG;
include_once $cfg['path']['i18n'] . LC_LANG . ".php";
$lang = new $langSelected();
$heute = date("Ymd", time());
// current date
/*
 * Template
 */
function tpl_translate($args)
{
    global $lang;
    return $lang->translate($args[0]);
}
$_tplset = 'screen';
$tpl = new IntegratedTemplateExtension($cfg['path']['template']);
开发者ID:BackupTheBerlios,项目名称:molecms,代码行数:31,代码来源:index.php

示例4: initTranslator

 function initTranslator()
 {
     $langSupported = array("de" => true, "en" => true);
     include_once 'HTTP.php';
     define("LC_LANG", HTTP::negotiateLanguage($langSupported, $this->cfg['i18n']['default']));
     $langSelected = 'rc_' . LC_LANG;
     include_once $this->cfg['i18n']['directory'] . LC_LANG . ".php";
     $this->lang = new $langSelected();
 }
开发者ID:BackupTheBerlios,项目名称:molecms,代码行数:9,代码来源:mms_application.php


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