From 10297299d4f9452e8ee6bc7b207a71ab4346279d Mon Sep 17 00:00:00 2001 From: Sandy Pleyte Date: Sat, 27 Dec 2014 17:09:27 +0100 Subject: [PATCH] Added a config param to force a specific language --- base.php | 7 +++++-- config_default.php | 8 +++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/base.php b/base.php index d8a507b..5afb4e2 100644 --- a/base.php +++ b/base.php @@ -192,6 +192,7 @@ function str_format($format) { * http://www.mind-it.info/2010/02/22/a-simple-approach-to-localization-in-php/ */ function localize($phrase, $count=-1, $reset=false) { + global $config; if ($count == 0) $phrase .= ".none"; 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 (is_null($translations)) { $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_file_en = NULL; diff --git a/config_default.php b/config_default.php index f94e89b..0749669 100644 --- a/config_default.php +++ b/config_default.php @@ -275,4 +275,10 @@ $config['cops_basic_authentication'] = NULL; /* 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'] = '';