From 44ad3426f83a846ab39a69ca007b0c3b5fb0de42 Mon Sep 17 00:00:00 2001 From: Moritz Warning Date: Sun, 29 Mar 2020 20:00:59 +0200 Subject: [PATCH] use browser language setting as first choice --- index.html | 2 +- index.js | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/index.html b/index.html index 5e99566..5d4a256 100644 --- a/index.html +++ b/index.html @@ -16,7 +16,7 @@ Logo
- diff --git a/index.js b/index.js index fadbfe7..b652815 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,5 @@ var current_model = {}; -var current_language = config.language; function $(id) { return document.getElementById(id); @@ -125,7 +124,7 @@ function setupSelectList(select, items, onselection) { // Change the translation of the entire document function translate() { - var mapping = translations[current_language]; + var mapping = translations[config.language]; for (var tr in mapping) { Array.from(document.getElementsByClassName(tr)) .forEach(e => { e.innerText = mapping[tr]; }) @@ -376,4 +375,11 @@ if (config.asu_url) { // hide fields updateImages(); + +var user_lang = (navigator.language || navigator.userLanguage).split('-')[0]; +if (user_lang in translations) { + config.language = user_lang; + $('language-selection').value = user_lang; +} + translate(); -- 2.30.2