From fa3baf8f869a8bb03a2b4af23eefd72bb10f9189 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 13 Sep 2019 21:16:22 +0200 Subject: [PATCH] i18n improvements --- lam/lib/config.inc | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lam/lib/config.inc b/lam/lib/config.inc index 540a7d69..22f91f32 100644 --- a/lam/lib/config.inc +++ b/lam/lib/config.inc @@ -75,12 +75,24 @@ function setlanguage() { break; } } - putenv("LANG=" . $code); // e.g. LANG=de_DE - setlocale(LC_ALL, $code); // set LC_ALL + putenv("LANG=$code"); // e.g. LANG=de_DE + putenv("LC_ALL=$code"); + putenv("LC_LANG=$code"); + putenv("LC_LANGUAGE=$code"); + $setLocaleResult = setlocale(LC_ALL, $code); // set LC_ALL + if ($setLocaleResult === false) { + logNewMessage(LOG_WARNING, "Unable to set locale, check if 'locale -a' returns $code"); + } $locdir = substr(__FILE__, 0, strlen(__FILE__) - 15) . "/locale"; // set path to translations bindtextdomain("messages", $locdir); - bind_textdomain_codeset("messages", $encoding); - textdomain("messages"); + $bindTextResult = bind_textdomain_codeset("messages", $encoding); + if (!is_string($bindTextResult)) { + logNewMessage(LOG_WARNING, "Unable to bind text domain, check if 'locale -a' returns $code"); + } + $textDomainResult = textdomain("messages"); + if (!is_string($textDomainResult)) { + logNewMessage(LOG_WARNING, "Unable to set text domain, check if 'locale -a' returns $code"); + } header("Content-type: text/html; charset=" . $encoding, true); }