From: Nik Okuntseff Date: Tue, 5 Apr 2016 16:16:02 +0000 (+0000) Subject: Improved browser language determination. X-Git-Tag: timetracker_1.19-1~1727 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=765181f88bd61e74e2836d1ede6465945e2226cf;p=timetracker.git Improved browser language determination. --- 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}