aboutsummaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
Diffstat (limited to 'web')
-rw-r--r--web/.jshintignore1
-rw-r--r--web/.jshintrc6
-rw-r--r--web/app/store/Languages.js8
-rw-r--r--web/app/view/LoginController.js2
-rw-r--r--web/locale.js20
5 files changed, 20 insertions, 17 deletions
diff --git a/web/.jshintignore b/web/.jshintignore
index fa3c21b68..d057f1b54 100644
--- a/web/.jshintignore
+++ b/web/.jshintignore
@@ -1,2 +1,3 @@
l10n/**
tests/**
+locale.js
diff --git a/web/.jshintrc b/web/.jshintrc
index 2039bc982..d547bfeb0 100644
--- a/web/.jshintrc
+++ b/web/.jshintrc
@@ -68,8 +68,8 @@
"globals" : {
"Ext" : false,
"ol" : false,
- "styles" : false,
- "strings" : false,
- "Traccar" : false
+ "Traccar" : false,
+ "Strings" : false,
+ "Locale" : false
}
}
diff --git a/web/app/store/Languages.js b/web/app/store/Languages.js
index 66d3e6176..594953480 100644
--- a/web/app/store/Languages.js
+++ b/web/app/store/Languages.js
@@ -22,16 +22,16 @@
data: (function () {
var code, data = [];
- for (code in availableLanguages) {
- if (availableLanguages.hasOwnProperty(code)) {
+ for (code in Locale.languages) {
+ if (Locale.languages.hasOwnProperty(code)) {
data.push({
code: code,
- name: availableLanguages[code].name
+ name: Locale.languages[code].name
});
}
}
return data;
- }())
+ })()
});
})();
diff --git a/web/app/view/LoginController.js b/web/app/view/LoginController.js
index f6a0414dd..dfff6b253 100644
--- a/web/app/view/LoginController.js
+++ b/web/app/view/LoginController.js
@@ -27,7 +27,7 @@
init: function () {
this.lookupReference('registerButton').setDisabled(
!Traccar.app.getServer().get('registration'));
- this.lookupReference('languageField').setValue(language);
+ this.lookupReference('languageField').setValue(Locale.language);
},
login: function () {
diff --git a/web/locale.js b/web/locale.js
index 43558d732..d200891d5 100644
--- a/web/locale.js
+++ b/web/locale.js
@@ -14,11 +14,13 @@
* limitations under the License.
*/
+var Locale = {};
+
Ext.Loader.setConfig({
disableCaching: false
});
-var availableLanguages = {
+Locale.languages = {
'bg': { name: 'Български', code: 'bg' },
'cs': { name: 'Čeština', code: 'cs' },
'de': { name: 'Deutsch', code: 'de' },
@@ -39,15 +41,15 @@ var availableLanguages = {
'zh': { name: '中文', code: 'zh_CN' }
};
-var language = Ext.Object.fromQueryString(window.location.search.substring(1)).locale;
-if (language === undefined) {
- language = window.navigator.userLanguage || window.navigator.language;
- language = language.substr(0, 2);
+Locale.language = Ext.Object.fromQueryString(window.location.search.substring(1)).locale;
+if (Locale.language === undefined) {
+ Locale.language = window.navigator.userLanguage || window.navigator.language;
+ Locale.language = Locale.language.substr(0, 2);
}
-if (!(language in availableLanguages)) {
- language = 'en'; // default
+if (!(Locale.language in Locale.languages)) {
+ Locale.language = 'en'; // default
}
-Ext.Loader.loadScript('/l10n/' + language + '.js');
-Ext.Loader.loadScript('//cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/locale/locale-' + availableLanguages[language].code + '.js');
+Ext.Loader.loadScript('/l10n/' + Locale.language + '.js');
+Ext.Loader.loadScript('//cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/locale/locale-' + Locale.languages[Locale.language].code + '.js');