From bed05af6748726c2260afbca62938855f5b477eb Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 28 Oct 2019 12:49:44 +0100 Subject: [PATCH] Fix some translation problems by forcing the LANGUAGE env variable value --- public_html/includes/class/class.LSsession.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/public_html/includes/class/class.LSsession.php b/public_html/includes/class/class.LSsession.php index 0342d88e..286a1f7a 100644 --- a/public_html/includes/class/class.LSsession.php +++ b/public_html/includes/class/class.LSsession.php @@ -388,12 +388,21 @@ class LSsession { if ($encoding) { $lang.='.'.$encoding; } - setlocale(LC_ALL, $lang); - bindtextdomain(LS_TEXT_DOMAIN, LS_I18N_DIR); - textdomain(LS_TEXT_DOMAIN); - + // Gettext firstly look the LANGUAGE env variable, so set it + putenv("LANGUAGE=$lang"); + + // Set the locale + if (setlocale(LC_ALL, $lang) === false) + LSlog :: error("An error occured setting locale to '$lang'"); + // Configure and set the text domain + $fullpath = bindtextdomain(LS_TEXT_DOMAIN, LS_I18N_DIR); + LSlog :: debug("Text domain fullpath is '$fullpath'."); + LSlog :: debug("Text domain is : ".textdomain(LS_TEXT_DOMAIN)); + + // Include local translation file self :: includeFile(LS_I18N_DIR.'/'.$lang.'/lang.php'); + // Include other local translation file(s) foreach (listFiles(LS_LOCAL_DIR.'/'.LS_I18N_DIR.'/'.$lang, '/^lang.+\.php$/') as $file) { $path = LS_LOCAL_DIR.'/'.LS_I18N_DIR."/$lang/$file"; LSlog :: debug("LSession :: setLocale() : Local '$lang.$encoding' : load translation file '$path'");