Merge pull request #189 from sndpl/feature/force-language

Added a config param to force a specific language
This commit is contained in:
Sébastien Lucas 2014-12-27 21:04:46 +01:00
當前提交 02a90bd7f0
共有 2 個檔案被更改,包括 12 行新增3 行删除

查看文件

@ -192,6 +192,7 @@ function str_format($format) {
* http://www.mind-it.info/2010/02/22/a-simple-approach-to-localization-in-php/ * http://www.mind-it.info/2010/02/22/a-simple-approach-to-localization-in-php/
*/ */
function localize($phrase, $count=-1, $reset=false) { function localize($phrase, $count=-1, $reset=false) {
global $config;
if ($count == 0) if ($count == 0)
$phrase .= ".none"; $phrase .= ".none";
if ($count == 1) if ($count == 1)
@ -207,8 +208,10 @@ function localize($phrase, $count=-1, $reset=false) {
/* If no instance of $translations has occured load the language file */ /* If no instance of $translations has occured load the language file */
if (is_null($translations)) { if (is_null($translations)) {
$lang = "en"; $lang = "en";
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) if (!empty($config['cops_language'])) {
{ $lang = $config['cops_language'];
}
elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
} }
$lang_file_en = NULL; $lang_file_en = NULL;

查看文件

@ -275,4 +275,10 @@
$config['cops_basic_authentication'] = NULL; $config['cops_basic_authentication'] = NULL;
/* Which template is used */ /* Which template is used */
$config['cops_template']= 'default'; $config['cops_template'] = 'default';
/*
* Set language code to force a language (see lang/ directory for available languages).
* When empty it will auto detect the language.
*/
$config['cops_language'] = '';