Browse Source

change language dynamically - bound to F8 key

pull/1/head
Friendika 10 years ago
parent
commit
08032e0453
6 changed files with 64 additions and 0 deletions
  1. +20
    -0
      boot.php
  2. +13
    -0
      include/main.js
  3. +1
    -0
      include/nav.php
  4. +18
    -0
      index.php
  5. +6
    -0
      view/theme/duepuntozero/style.css
  6. +6
    -0
      view/theme/loozah/style.css

+ 20
- 0
boot.php View File

@ -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;
}}

+ 13
- 0
include/main.js View File

@ -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) {


+ 1
- 0
include/nav.php View File

@ -16,6 +16,7 @@ function nav(&$a) {
*/
$a->page['nav'] .= '<div id="panel" style="display: none;"></div>' ;
$a->page['nav'] .= lang_selector();
/**
*


+ 18
- 0
index.php View File

@ -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);
@ -86,6 +91,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.


+ 6
- 0
view/theme/duepuntozero/style.css View File

@ -2183,3 +2183,9 @@ a.mail-list-link {
.side-link {
margin-bottom: 15px;
}
#language-selector {
position: absolute;
top: 0;
left: 0;
)

+ 6
- 0
view/theme/loozah/style.css View File

@ -2205,3 +2205,9 @@ a.mail-list-link {
.side-link {
margin-bottom: 15px;
}
#language-selector {
position: absolute;
top: 0;
left: 0;
)

Loading…
Cancel
Save