provide ability to unset session language
This commit is contained in:
parent
030e1e82c3
commit
542aa22eb9
2 changed files with 12 additions and 2 deletions
|
@ -847,10 +847,16 @@ function lang_selector() {
|
||||||
$o .= '<form action="" method="post" ><select name="system_language" onchange="this.form.submit();" >';
|
$o .= '<form action="" method="post" ><select name="system_language" onchange="this.form.submit();" >';
|
||||||
$langs = glob('view/*/strings.php');
|
$langs = glob('view/*/strings.php');
|
||||||
if(is_array($langs) && count($langs)) {
|
if(is_array($langs) && count($langs)) {
|
||||||
|
$langs[] = '';
|
||||||
if(! in_array('view/en/strings.php',$langs))
|
if(! in_array('view/en/strings.php',$langs))
|
||||||
$langs[] = 'view/en/';
|
$langs[] = 'view/en/';
|
||||||
asort($langs);
|
asort($langs);
|
||||||
foreach($langs as $l) {
|
foreach($langs as $l) {
|
||||||
|
if($l == '') {
|
||||||
|
$default_selected = ((! x($_SESSION,'language')) ? ' selected="selected" ' : '');
|
||||||
|
$o .= '<option value="" ' . $default_selected . '>' . t('default') . '</option>';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$ll = substr($l,5);
|
$ll = substr($l,5);
|
||||||
$ll = substr($ll,0,strrpos($ll,'/'));
|
$ll = substr($ll,0,strrpos($ll,'/'));
|
||||||
$selected = (($ll === $lang) ? ' selected="selected" ' : '');
|
$selected = (($ll === $lang) ? ' selected="selected" ' : '');
|
||||||
|
|
|
@ -84,8 +84,12 @@ session_start();
|
||||||
* We have to do it here because the session was just now opened.
|
* We have to do it here because the session was just now opened.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(x($_POST,'system_language'))
|
if(array_key_exists('system_language',$_POST)) {
|
||||||
$_SESSION['language'] = $_POST['system_language'];
|
if(strlen($_POST['system_language']))
|
||||||
|
$_SESSION['language'] = $_POST['system_language'];
|
||||||
|
else
|
||||||
|
unset($_SESSION['language']);
|
||||||
|
}
|
||||||
if((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) {
|
if((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) {
|
||||||
$lang = $_SESSION['language'];
|
$lang = $_SESSION['language'];
|
||||||
load_translation_table($lang);
|
load_translation_table($lang);
|
||||||
|
|
Loading…
Reference in a new issue