From db8dba3f48ba6f196fdcca11db03abbeafe87fb3 Mon Sep 17 00:00:00 2001 From: Jared Hancock <jared@osticket.com> Date: Wed, 23 Jul 2014 14:40:33 -0500 Subject: [PATCH] i18n: Clients can elect a language preference --- include/class.client.php | 4 ++++ include/client/profile.inc.php | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/include/class.client.php b/include/class.client.php index 5e2485ed0..152c6dee5 100644 --- a/include/class.client.php +++ b/include/class.client.php @@ -375,6 +375,10 @@ class ClientAccount extends UserAccount { $this->set('timezone_id', $vars['timezone_id']); $this->set('dst', isset($vars['dst']) ? 1 : 0); + // Change language + $this->set('lang', $vars['lang'] ?: null); + $_SESSION['client:lang'] = null; + TextDomain::configureForUser($this); if ($vars['backend']) { $this->set('backend', $vars['backend']); diff --git a/include/client/profile.inc.php b/include/client/profile.inc.php index f500e1cb9..89fa70a09 100644 --- a/include/client/profile.inc.php +++ b/include/client/profile.inc.php @@ -48,6 +48,24 @@ if ($acct = $thisclient->getAccount()) { <strong><?php echo Format::date($cfg->getDateTimeFormat(),Misc::gmtime(),$info['tz_offset'],$info['dst']); ?></strong>)</em> </td> </tr> + <tr> + <td width="180"> + <?php echo __('Preferred Language'); ?>: + </td> + <td> + <?php + $langs = Internationalization::availableLanguages(); ?> + <select name="lang"> + <option value="">— <?php echo __('Use Browser Preference'); ?> —</option> +<?php foreach($langs as $l) { +$selected = ($info['lang'] == $l['code']) ? 'selected="selected"' : ''; ?> + <option value="<?php echo $l['code']; ?>" <?php echo $selected; + ?>><?php echo Internationalization::getLanguageDescription($l['code']); ?></option> +<?php } ?> + </select> + <span class="error"> <?php echo $errors['lang']; ?></span> + </td> + </tr> <?php if ($acct->isPasswdResetEnabled()) { ?> <tr> <td colspan=2"> -- GitLab