summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/codeq/core.js19
1 files changed, 14 insertions, 5 deletions
diff --git a/js/codeq/core.js b/js/codeq/core.js
index 148cdeb..441c257 100644
--- a/js/codeq/core.js
+++ b/js/codeq/core.js
@@ -199,6 +199,7 @@
'log': log,
+ 'availableLangs': [], // filled at boot from 'supportedLangs'
'supportedLangs': {
'en': 'English',
'sl': 'Slovenščina'
@@ -371,12 +372,20 @@
$(document).ready(function () {
// set the language
- var lang = navigator.language || navigator.browserLanguage;
- if (typeof lang === 'string') {
- lang = lang.split('-')[0]; // truncate the language variant, in eg. en-US
- if (lang in codeq.supportedLangs) codeq.lang = lang;
+ var navigatorLang = navigator.language || navigator.browserLanguage, // language reported by browser
+ lang = null, // the translation language that will be chosen
+ key;
+ if (typeof navigatorLang === 'string') {
+ navigatorLang = navigatorLang.split('-')[0]; // truncate the language variant, in eg. en-US
}
- codeq.setLang(lang); // initial language setting
+ else navigatorLang = 'en';
+ for (key in codeq.supportedLangs) {
+ if (!codeq.supportedLangs.hasOwnProperty(key)) continue;
+ if (key === navigatorLang) lang = key; // we support the browser's language
+ codeq.availableLangs.push(key);
+ }
+
+ codeq.setLang(lang || 'en'); // initial language setting
// go to login
codeq.globalStateMachine.transition('login');