aboutsummaryrefslogtreecommitdiff
path: root/web/load.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2017-08-06 21:37:47 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2017-08-06 21:37:47 +1200
commitac0d6b1bf5833536b28aabad25b628ea0322fb76 (patch)
tree3128f420df950e5e0fa7de4ab8ab670f7d89caba /web/load.js
parent3f4190a60c119f55822b218cc54fff22ff3c2ac5 (diff)
downloadtrackermap-web-ac0d6b1bf5833536b28aabad25b628ea0322fb76.tar.gz
trackermap-web-ac0d6b1bf5833536b28aabad25b628ea0322fb76.tar.bz2
trackermap-web-ac0d6b1bf5833536b28aabad25b628ea0322fb76.zip
Fallback to default language
Diffstat (limited to 'web/load.js')
-rw-r--r--web/load.js27
1 files changed, 19 insertions, 8 deletions
diff --git a/web/load.js b/web/load.js
index 568a4bf8..86b98290 100644
--- a/web/load.js
+++ b/web/load.js
@@ -1,5 +1,5 @@
(function () {
- var debugMode, touchMode, locale, localeParameter, extjsVersion, proj4jsVersion, fontAwesomeVersion, olVersion, i, language, languages;
+ var debugMode, touchMode, locale, localeParameter, extjsVersion, proj4jsVersion, fontAwesomeVersion, olVersion, i, language, languages, languageDefault;
function addStyleFile(file) {
var link = document.createElement('link');
@@ -83,6 +83,7 @@
'zh_TW': { name: '中文 (Taiwan)', code: 'zh_TW' }
};
+ languageDefault = 'en';
localeParameter = window.location.search.match(/locale=([^&#]+)/);
locale.language = localeParameter && localeParameter[1];
if (!(locale.language in locale.languages)) {
@@ -90,7 +91,7 @@
language = window.navigator.userLanguage || window.navigator.language;
languages.push(language);
languages.push(language.substr(0, 2));
- languages.push('en'); //default
+ languages.push(languageDefault);
for (i = 0; i < languages.length; i++) {
language = languages[i].replace('-', '_');
if (language in locale.languages) {
@@ -109,14 +110,24 @@
}
Ext.Ajax.request({
- url: 'l10n/' + Locale.language + '.json',
+ url: 'l10n/' + languageDefault + '.json',
callback: function (options, success, response) {
window.Strings = Ext.decode(response.responseText);
-
- if (debugMode) {
- addScriptFile('app.js');
- } else {
- addScriptFile('app.min.js');
+ if (Locale.language !== languageDefault) {
+ Ext.Ajax.request({
+ url: 'l10n/' + Locale.language + '.json',
+ callback: function (options, success, response) {
+ var key, data = Ext.decode(response.responseText);
+ for (key in data) {
+ if (data.hasOwnProperty(key)) {
+ window.Strings[key] = data[key];
+ }
+ }
+ addScriptFile(debugMode ? 'app.js' : 'app.min.js');
+ }
+ });
+ } else {
+ addScriptFile(debugMode ? 'app.js' : 'app.min.js');
}
}
});