1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2025-07-06 23:37:40 +02:00

Fix: Evaluate HTTP_ACCEPT_LANGUAGE, check ['locale']

This commit is contained in:
billz 2025-03-20 02:08:54 -07:00
parent 16f6b7f979
commit 6adeab7586

View File

@ -11,7 +11,7 @@
* *
* Refer to: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4 * Refer to: https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4
*/ */
if (empty($_SESSION['locale']) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) >= 2) { if (empty($_SESSION['locale']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE']) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) >= 2) {
$lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2);
switch ($lang) { switch ($lang) {
case "de": case "de":
@ -90,9 +90,10 @@ if (empty($_SESSION['locale']) && strlen($_SERVER['HTTP_ACCEPT_LANGUAGE']) >= 2)
// Use: 'sudo raspi-configure' and select 'Localisation Options' // Use: 'sudo raspi-configure' and select 'Localisation Options'
// activate the locale setting // activate the locale setting
putenv("LANG=" . $_SESSION['locale']); if (!empty($_SESSION['locale'])) {
setlocale(LC_ALL, $_SESSION['locale']); putenv("LANG=" . $_SESSION['locale']);
setlocale(LC_ALL, $_SESSION['locale']);
}
bindtextdomain(LOCALE_DOMAIN, LOCALE_ROOT); bindtextdomain(LOCALE_DOMAIN, LOCALE_ROOT);
bind_textdomain_codeset(LOCALE_DOMAIN, 'UTF-8'); bind_textdomain_codeset(LOCALE_DOMAIN, 'UTF-8');