Commit ba3daca2 authored by Tobias Zeumer's avatar Tobias Zeumer

Detect browser language and allow override with url parameter; resolves #54

parent ed2b18ea
......@@ -11,9 +11,18 @@
rsort($last_modified);
$gmt_mtime = gmdate('D, d M Y H:i:s', $last_modified[0]) . ' GMT';
header("Last-Modified: " . $gmt_mtime);
// Accepted languages
$LANG_list = array_flip(array('de', 'en'));
// Use Browser language by default
$LANG = strtolower(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2));
// Override if language is set explicitly
if (isset($_REQUEST['lang'])) $LANG = strtolower($_REQUEST['lang']);
// Do we support the detected/selected language? Use englisch for any unkown language.
if (!isset($LANG_list[$LANG])) $LANG = 'en';
?>
<!doctype html>
<html lang="en">
<html lang="<?php echo $LANG ?>">
<!-- http://localhost/_tub/svg/index.html?level=og1&highlight-id=eg_raum_0006 -->
<head>
<title lang="de" data-lang-token="page-title">TUHH Universitätsbibliothek: Übersichtsplan</title>
......
......@@ -83,9 +83,17 @@ $( document ).ready(function() {
// $('.lng_' + lang.currentLang).toggle();
// Language: create language switcher instance
// Get initial language from html lang attribute (set by php)
let user_lang = $("html").attr("lang");
lang.dynamic('en', 'locale/en.json');
lang.init({defaultLang: 'de', currentLang: 'de'});
lang.init({defaultLang: 'de', currentLang: user_lang});
// toggle description language in legend and switch button
// @todo: this is partially redundant to the tgl_lng onClick event code
if (user_lang == 'en') {
$('.lng_en, .lng_de').toggle();
$('#tgl_lng').html('DE');
}
// Use https://github.com/timmywil/jquery.panzoom for zooming (pinch) and panning
var $panzoom = $("#tubhh").panzoom({
minScale: 0.8,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment