From 30285062506005d21b085e7402b2b24be35c31e5 Mon Sep 17 00:00:00 2001
From: Jared Hancock <jared@osticket.com>
Date: Sat, 18 Oct 2014 19:33:13 -0500
Subject: [PATCH] i18n: Fixup header and footer language hints

---
 include/client/header.inc.php | 5 ++++-
 include/staff/footer.inc.php  | 4 +++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/include/client/header.inc.php b/include/client/header.inc.php
index ac28febfb..7d7652f5e 100644
--- a/include/client/header.inc.php
+++ b/include/client/header.inc.php
@@ -85,11 +85,14 @@ if (($lang = Internationalization::getCurrentLanguage())
 if (($all_langs = Internationalization::getConfiguredSystemLanguages())
     && (count($all_langs) > 1)
 ) {
+    $qs = array();
+    parse_str($_SERVER['QUERY_STRING'], $qs);
     foreach ($all_langs as $code=>$info) {
         list($lang, $locale) = explode('_', $code);
+        $qs['lang'] = $code;
 ?>
         <a class="flag flag-<?php echo strtolower($locale ?: $info['flag'] ?: $lang); ?>"
-            href="?<?php echo urlencode($_GET['QUERY_STRING']); ?>&amp;lang=<?php echo $code;
+            href="?<?php echo http_build_query($qs);
             ?>" title="<?php echo Internationalization::getLanguageDescription($code); ?>">&nbsp;</a>
 <?php }
 } ?>
diff --git a/include/staff/footer.inc.php b/include/staff/footer.inc.php
index 12c9b034d..2c0c45eb0 100644
--- a/include/staff/footer.inc.php
+++ b/include/staff/footer.inc.php
@@ -51,7 +51,9 @@ if ($.support.pjax) {
 }
 </script>
 <?php
-if ($thisstaff && $thisstaff->getLanguage() != 'en_US') { ?>
+if ($thisstaff
+        && ($lang = $thisstaff->getLanguage())
+        && 0 !== strcasecmp($lang, 'en_US')) { ?>
     <script type="text/javascript" src="ajax.php/i18n/<?php
         echo $thisstaff->getLanguage(); ?>/js"></script>
 <?php } ?>
-- 
GitLab