From 27c095dfdb55448ed8e6807eedce5f0744e5052b Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Wed, 23 Jul 2014 14:51:17 -0500 Subject: [PATCH] i18n: Honor RTL setting in client portal --- include/class.i18n.php | 9 +++++++++ include/class.translation.php | 5 +---- include/client/header.inc.php | 7 ++++++- include/staff/header.inc.php | 2 +- 4 files changed, 17 insertions(+), 6 deletions(-) diff --git a/include/class.i18n.php b/include/class.i18n.php index 2a28487ec..f412e5f9e 100644 --- a/include/class.i18n.php +++ b/include/class.i18n.php @@ -315,6 +315,15 @@ class Internationalization { return $best_match_langcode; } + static function getCurrentLanguage($user=false) { + global $thisstaff, $thisclient, $cfg; + + $user = $user ?: $thisstaff ?: $thisclient; + if ($user && method_exists($user, 'getLanguage')) + return $user->getLanguage(); + return Internationalization::getDefaultLanguage(); + } + static function bootstrap() { require_once INCLUDE_DIR . 'class.translation.php'; diff --git a/include/class.translation.php b/include/class.translation.php index f4ee44662..b6fe18c2b 100644 --- a/include/class.translation.php +++ b/include/class.translation.php @@ -708,10 +708,7 @@ class TextDomain { } static function configureForUser($user=false) { - if ($user && method_exists($user, 'getLanguage')) - $lang = $user->getLanguage(); - else - $lang = Internationalization::getDefaultLanguage(); + $lang = Internationalization::getCurrentLanguage($user); // Define locale for C-libraries putenv('LC_ALL=' . $lang); diff --git a/include/client/header.inc.php b/include/client/header.inc.php index 086ff99d8..efeffb513 100644 --- a/include/client/header.inc.php +++ b/include/client/header.inc.php @@ -8,7 +8,12 @@ $signout_url = ROOT_PATH . "logout.php?auth=".$ost->getLinkToken(); header("Content-Type: text/html; charset=UTF-8\r\n"); ?> <!DOCTYPE html> -<html> +<html <?php +if (($lang = Internationalization::getCurrentLanguage()) + && ($info = Internationalization::getLanguageInfo($lang)) + && (@$info['direction'] == 'rtl')) + echo 'dir="rtl" class="rtl"'; +?>> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> diff --git a/include/staff/header.inc.php b/include/staff/header.inc.php index 1185f2e19..8754a2926 100644 --- a/include/staff/header.inc.php +++ b/include/staff/header.inc.php @@ -1,7 +1,7 @@ <?php if (!isset($_SERVER['HTTP_X_PJAX'])) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html <?php -if ($thisstaff && ($lang = $thisstaff->getLanguage()) +if (($lang = Internationalization::getCurrentLanguage()) && ($info = Internationalization::getLanguageInfo($lang)) && (@$info['direction'] == 'rtl')) echo 'dir="rtl" class="rtl"'; -- GitLab