aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--boot.php20
-rw-r--r--include/main.js13
-rw-r--r--include/nav.php1
-rw-r--r--index.php18
-rw-r--r--view/theme/duepuntozero/style.css6
-rw-r--r--view/theme/loozah/style.css6
6 files changed, 64 insertions, 0 deletions
diff --git a/boot.php b/boot.php
index abbacdf4e..8a2706252 100644
--- a/boot.php
+++ b/boot.php
@@ -2669,3 +2669,23 @@ function extract_item_authors($arr,$uid) {
}
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;
+}}
diff --git a/include/main.js b/include/main.js
index 750cce74c..18e884b31 100644
--- a/include/main.js
+++ b/include/main.js
@@ -26,6 +26,7 @@
var pr = 0;
var liking = 0;
var in_progress = false;
+ var langSelect = false;
$(document).ready(function() {
$.ajaxSetup({cache: false});
@@ -45,6 +46,18 @@
$('#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.
// update: incompatible usage of onKeyDown vs onKeyPress
// if(event.keyCode == '36' && event.shiftKey == true) {
diff --git a/include/nav.php b/include/nav.php
index db3b909af..b8b65f84d 100644
--- a/include/nav.php
+++ b/include/nav.php
@@ -16,6 +16,7 @@ function nav(&$a) {
*/
$a->page['nav'] .= '<div id="panel" style="display: none;"></div>' ;
+ $a->page['nav'] .= lang_selector();
/**
*
diff --git a/index.php b/index.php
index ab722df2a..9412c1e3b 100644
--- a/index.php
+++ b/index.php
@@ -42,6 +42,11 @@ if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
} else {
$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);
@@ -87,6 +92,19 @@ $a->init_pagehead();
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.
* Apache/PHP lumps the Link: headers into one - and other services might not be able to parse it
diff --git a/view/theme/duepuntozero/style.css b/view/theme/duepuntozero/style.css
index 042cc380f..0d59b6590 100644
--- a/view/theme/duepuntozero/style.css
+++ b/view/theme/duepuntozero/style.css
@@ -2183,3 +2183,9 @@ a.mail-list-link {
.side-link {
margin-bottom: 15px;
}
+
+#language-selector {
+ position: absolute;
+ top: 0;
+ left: 0;
+)
diff --git a/view/theme/loozah/style.css b/view/theme/loozah/style.css
index a61838157..566220711 100644
--- a/view/theme/loozah/style.css
+++ b/view/theme/loozah/style.css
@@ -2205,3 +2205,9 @@ a.mail-list-link {
.side-link {
margin-bottom: 15px;
}
+
+#language-selector {
+ position: absolute;
+ top: 0;
+ left: 0;
+)