change language dynamically - bound to F8 key
This commit is contained in:
parent
75ad3219e6
commit
08032e0453
6 changed files with 64 additions and 0 deletions
20
boot.php
20
boot.php
|
@ -2669,3 +2669,23 @@ function extract_item_authors($arr,$uid) {
|
||||||
}
|
}
|
||||||
return array();
|
return array();
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
if(! function_exists('lang_selector')) {
|
||||||
|
function lang_selector() {
|
||||||
|
global $lang;
|
||||||
|
$o .= '<div id="language-selector" style="display: none;" >';
|
||||||
|
$o .= '<form action="" method="post" ><select name="system_language" onchange="this.form.submit();" >';
|
||||||
|
$langs = glob('view/*/strings.php');
|
||||||
|
if(is_array($langs) && count($langs)) {
|
||||||
|
if(! in_array('view/en/strings.php',$langs))
|
||||||
|
$langs[] = 'view/en/';
|
||||||
|
foreach($langs as $l) {
|
||||||
|
$ll = substr($l,5);
|
||||||
|
$ll = substr($ll,0,strrpos($ll,'/'));
|
||||||
|
$selected = (($ll === $lang) ? ' selected="selected" ' : '');
|
||||||
|
$o .= '<option value="' . $ll . '"' . $selected . '>' . $ll . '</option>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$o .= '</select></form></div>';
|
||||||
|
return $o;
|
||||||
|
}}
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
var pr = 0;
|
var pr = 0;
|
||||||
var liking = 0;
|
var liking = 0;
|
||||||
var in_progress = false;
|
var in_progress = false;
|
||||||
|
var langSelect = false;
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$.ajaxSetup({cache: false});
|
$.ajaxSetup({cache: false});
|
||||||
|
@ -45,6 +46,18 @@
|
||||||
$('#pause').html('');
|
$('#pause').html('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// F8 - show/hide language selector
|
||||||
|
if(event.keyCode == '119') {
|
||||||
|
if(langSelect) {
|
||||||
|
langSelect = false;
|
||||||
|
$('#language-selector').hide();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
langSelect = true;
|
||||||
|
$('#language-selector').show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// this is shift-home on FF, but $ on IE, disabling until I figure out why the diff.
|
// this is shift-home on FF, but $ on IE, disabling until I figure out why the diff.
|
||||||
// update: incompatible usage of onKeyDown vs onKeyPress
|
// update: incompatible usage of onKeyDown vs onKeyPress
|
||||||
// if(event.keyCode == '36' && event.shiftKey == true) {
|
// if(event.keyCode == '36' && event.shiftKey == true) {
|
||||||
|
|
|
@ -16,6 +16,7 @@ function nav(&$a) {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$a->page['nav'] .= '<div id="panel" style="display: none;"></div>' ;
|
$a->page['nav'] .= '<div id="panel" style="display: none;"></div>' ;
|
||||||
|
$a->page['nav'] .= lang_selector();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
18
index.php
18
index.php
|
@ -42,6 +42,11 @@ if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
|
||||||
} else {
|
} else {
|
||||||
$lang = ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en');
|
$lang = ((isset($a->config['system']['language'])) ? $a->config['system']['language'] : 'en');
|
||||||
}
|
}
|
||||||
|
if(x($_POST,'system_language'))
|
||||||
|
if(x($_SESSION,'language'))
|
||||||
|
$lang = $_SESSION['language'];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
load_translation_table($lang);
|
load_translation_table($lang);
|
||||||
|
|
||||||
|
@ -86,6 +91,19 @@ $a->init_pagehead();
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Language was set earlier, but we can over-ride it in the session.
|
||||||
|
* We have to do it here because the session was just now opened.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if(x($_POST,'system_language'))
|
||||||
|
$_SESSION['language'] = $_POST['system_language'];
|
||||||
|
if((x($_SESSION,'language')) && ($_SESSION['language'] !== $lang)) {
|
||||||
|
$lang = $_SESSION['language'];
|
||||||
|
load_translation_table($lang);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* For Mozilla auth manager - still needs sorting, and this might conflict with LRDD header.
|
* For Mozilla auth manager - still needs sorting, and this might conflict with LRDD header.
|
||||||
|
|
|
@ -2183,3 +2183,9 @@ a.mail-list-link {
|
||||||
.side-link {
|
.side-link {
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#language-selector {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
)
|
||||||
|
|
|
@ -2205,3 +2205,9 @@ a.mail-list-link {
|
||||||
.side-link {
|
.side-link {
|
||||||
margin-bottom: 15px;
|
margin-bottom: 15px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#language-selector {
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in a new issue