From 765181f88bd61e74e2836d1ede6465945e2226cf Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Tue, 5 Apr 2016 16:16:02 +0000 Subject: [PATCH] Improved browser language determination. --- WEB-INF/lib/I18n.class.php | 15 ++++++++++----- WEB-INF/templates/footer.tpl | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/WEB-INF/lib/I18n.class.php b/WEB-INF/lib/I18n.class.php index 57fc1c47..a9f1b434 100644 --- a/WEB-INF/lib/I18n.class.php +++ b/WEB-INF/lib/I18n.class.php @@ -134,13 +134,18 @@ class I18n { $lang_prefs = explode(',', $acclang); foreach ($lang_prefs as $lang_pref) { $lang_pref_parts = explode(';', trim($lang_pref)); - if ($this->hasLang($lang_pref_parts[0])) { - return $lang_pref_parts[0]; // Return full language designation, such as pt-BR. + $lang = $lang_pref_parts[0]; + if ($this->hasLang($lang)) { + return $lang; // Return full language designation (if available), such as pt-BR. } - $lang_parts = explode('-', trim($lang_pref_parts[0])); + + if (strlen($lang) <= 2) + continue; // Do not bother determining main language because we already have it. + + $lang_parts = explode('-', trim($lang)); $lang_main = $lang_parts[0]; - if ($lang_main != $lang_pref_parts[0] && $this->hasLang($lang_main)) { - return $lang_main; // Return main language designation, such as pt. + if ($lang_main != $lang && $this->hasLang($lang_main)) { + return $lang_main; // Return main language designation, such as pt. } } return false; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 4f386b58..55aa98db 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.9.24.3489 | Copyright © Anuko | +  Anuko Time Tracker 1.9.24.3490 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1