aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2015-07-26 21:49:57 +1200
committerAnton Tananaev <anton.tananaev@gmail.com>2015-07-26 21:49:57 +1200
commitd8cd9c2bba2b3bea5f6af15189f868fa6cffd9b0 (patch)
treed5db965d1e8aaece457f300ddc432caf5b6a25d5
parent15a540f2b585bb8c7cd7097386957ee332e3d202 (diff)
downloadtrackermap-server-d8cd9c2bba2b3bea5f6af15189f868fa6cffd9b0.tar.gz
trackermap-server-d8cd9c2bba2b3bea5f6af15189f868fa6cffd9b0.tar.bz2
trackermap-server-d8cd9c2bba2b3bea5f6af15189f868fa6cffd9b0.zip
Implement language selection
-rw-r--r--web/app.js22
-rw-r--r--web/app/Application.js3
-rw-r--r--web/app/store/CommandTypes.js2
-rw-r--r--web/app/store/DistanceUnits.js2
-rw-r--r--web/app/store/Languages.js32
-rw-r--r--web/app/store/MapTypes.js2
-rw-r--r--web/app/store/SpeedUnits.js2
-rw-r--r--web/app/store/TimeUnits.js2
-rw-r--r--web/app/view/login/Login.js11
-rw-r--r--web/app/view/login/LoginController.js20
-rw-r--r--web/l10n/en.js1
11 files changed, 82 insertions, 17 deletions
diff --git a/web/app.js b/web/app.js
index 8ddceffce..ed04f3ece 100644
--- a/web/app.js
+++ b/web/app.js
@@ -19,16 +19,16 @@ Ext.Loader.setConfig({
});
{
- var available = {
- 'cn': true,
- 'de': true,
- 'en': true,
- 'es': true,
- 'fr': true,
- 'pl': true,
- 'pt': true,
- 'ru': true,
- 'th': true
+ var availableLanguages = {
+ 'cn': '中文',
+ 'de': 'Deutsch',
+ 'en': 'English',
+ 'es': 'Español',
+ 'fr': 'Français',
+ 'pl': 'Polski',
+ 'pt': 'Português',
+ 'ru': 'Русский',
+ 'th': 'ไทย'
};
var language = Ext.Object.fromQueryString(window.location.search.substring(1)).locale;
@@ -37,7 +37,7 @@ Ext.Loader.setConfig({
language = language.substr(0, 2);
}
- if (!(language in available)) {
+ if (!(language in availableLanguages)) {
language = 'en'; // default
}
diff --git a/web/app/Application.js b/web/app/Application.js
index b93ef2f28..88745265b 100644
--- a/web/app/Application.js
+++ b/web/app/Application.js
@@ -42,7 +42,8 @@ Ext.define('Traccar.Application', {
'DistanceUnits',
'SpeedUnits',
'CommandTypes',
- 'TimeUnits'
+ 'TimeUnits',
+ 'Languages'
],
controllers: [
diff --git a/web/app/store/CommandTypes.js b/web/app/store/CommandTypes.js
index 3906eb9a1..bb5a4d024 100644
--- a/web/app/store/CommandTypes.js
+++ b/web/app/store/CommandTypes.js
@@ -17,7 +17,7 @@
Ext.define('Traccar.store.CommandTypes', {
extend: 'Ext.data.Store',
fields: ['key', 'name'],
- data : [
+ data: [
{'key': 'positionStop', 'name': strings.command_position_stop},
{'key': 'positionFix', 'name': strings.command_position_fix},
{'key': 'engineStop', 'name': strings.command_engine_stop},
diff --git a/web/app/store/DistanceUnits.js b/web/app/store/DistanceUnits.js
index b3d342fc6..be17466ec 100644
--- a/web/app/store/DistanceUnits.js
+++ b/web/app/store/DistanceUnits.js
@@ -17,7 +17,7 @@
Ext.define('Traccar.store.DistanceUnits', {
extend: 'Ext.data.Store',
fields: ['key', 'name'],
- data : [
+ data: [
{'key': 'km', 'name': strings.shared_km},
{'key': 'mi', 'name': strings.shared_mi}
]
diff --git a/web/app/store/Languages.js b/web/app/store/Languages.js
new file mode 100644
index 000000000..8d1a98552
--- /dev/null
+++ b/web/app/store/Languages.js
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2015 Anton Tananaev (anton.tananaev@gmail.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+Ext.define('Traccar.store.Languages', {
+ extend: 'Ext.data.Store',
+ fields: ['code', 'name'],
+ data: function() {
+ var data = [];
+ for (var code in availableLanguages) {
+ if (availableLanguages.hasOwnProperty(code)) {
+ data.push({
+ 'code': code,
+ 'name': availableLanguages[code]
+ });
+ }
+ }
+ return data;
+ }()
+});
diff --git a/web/app/store/MapTypes.js b/web/app/store/MapTypes.js
index ef63fd92b..4d37e133d 100644
--- a/web/app/store/MapTypes.js
+++ b/web/app/store/MapTypes.js
@@ -17,7 +17,7 @@
Ext.define('Traccar.store.MapTypes', {
extend: 'Ext.data.Store',
fields: ['key', 'name'],
- data : [
+ data: [
{'key': 'osm', 'name': strings.map_osm},
{'key': 'bingRoad', 'name': strings.map_bing_road},
{'key': 'bingAerial', 'name': strings.map_bing_aerial}
diff --git a/web/app/store/SpeedUnits.js b/web/app/store/SpeedUnits.js
index f4d4b8266..95c7fbc3b 100644
--- a/web/app/store/SpeedUnits.js
+++ b/web/app/store/SpeedUnits.js
@@ -17,7 +17,7 @@
Ext.define('Traccar.store.SpeedUnits', {
extend: 'Ext.data.Store',
fields: ['key', 'name'],
- data : [
+ data: [
{'key': 'kph', 'name': strings.shared_kph},
{'key': 'mph', 'name': strings.shared_mph}
],
diff --git a/web/app/store/TimeUnits.js b/web/app/store/TimeUnits.js
index e8cda7b26..f41ee5e2f 100644
--- a/web/app/store/TimeUnits.js
+++ b/web/app/store/TimeUnits.js
@@ -17,7 +17,7 @@
Ext.define('Traccar.store.TimeUnits', {
extend: 'Ext.data.Store',
fields: ['multiplier', 'name'],
- data : [
+ data: [
{'multiplier': 1, 'name': strings.shared_second},
{'multiplier': 60, 'name': strings.shared_minute},
{'multiplier': 3600, 'name': strings.shared_hour}
diff --git a/web/app/view/login/Login.js b/web/app/view/login/Login.js
index fdaaadcfb..49fc8e011 100644
--- a/web/app/view/login/Login.js
+++ b/web/app/view/login/Login.js
@@ -33,6 +33,17 @@ Ext.define('Traccar.view.login.Login', {
reference: 'form',
items: [{
+ xtype: 'combobox',
+ name: 'language',
+ fieldLabel: strings.login_language,
+ store: 'Languages',
+ displayField: 'name',
+ valueField: 'code',
+ submitValue: false,
+ listeners: {
+ select: 'onSelectLanguage'
+ }
+ }, {
xtype: 'textfield',
name: 'email',
fieldLabel: strings.user_email,
diff --git a/web/app/view/login/LoginController.js b/web/app/view/login/LoginController.js
index e94d0de9d..6620e07df 100644
--- a/web/app/view/login/LoginController.js
+++ b/web/app/view/login/LoginController.js
@@ -28,6 +28,26 @@ Ext.define('Traccar.view.login.LoginController', {
);
},
+ onSelectLanguage: function(selected) {
+ var paramName = 'locale';
+ var paramValue = selected.getValue();
+ var url = window.location.href;
+ if (url.indexOf(paramName + '=') >= 0) {
+ var prefix = url.substring(0, url.indexOf(paramName));
+ var suffix = url.substring(url.indexOf(paramName));
+ suffix = suffix.substring(suffix.indexOf("=") + 1);
+ suffix = (suffix.indexOf('&') >= 0) ? suffix.substring(suffix.indexOf('&')) : '';
+ url = prefix + paramName + "=" + paramValue + suffix;
+ } else {
+ if (url.indexOf('?') < 0) {
+ url += '?' + paramName + '=' + paramValue;
+ } else {
+ url += '&' + paramName + '=' + paramValue;
+ }
+ }
+ window.location.href = url;
+ },
+
onAfterRender: function(field) {
field.focus();
},
diff --git a/web/l10n/en.js b/web/l10n/en.js
index b25fc7231..e32e869d8 100644
--- a/web/l10n/en.js
+++ b/web/l10n/en.js
@@ -23,6 +23,7 @@ var strings = {
user_admin: 'Admin',
login_title: 'Login',
+ login_language: 'Language',
login_register: 'Register',
login_login: 'Login',
login_failed: 'Incorrect email address or password',