From 67dc1c43932bffaf9df2c9ec201cff879d0226d9 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sat, 25 Apr 2015 16:51:54 +1200 Subject: Support interface localization --- web/Application.js | 38 +++++++++++++++++++++++++++++--------- web/Strings-ru.js | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 9 deletions(-) create mode 100644 web/Strings-ru.js (limited to 'web') diff --git a/web/Application.js b/web/Application.js index 2cd8df2a0..c522d50f7 100644 --- a/web/Application.js +++ b/web/Application.js @@ -14,15 +14,35 @@ * limitations under the License. */ -Ext.application({ - name: 'Traccar', - requires: [ - 'Strings', - 'Styles', - 'Login' - ], +Ext.Loader.setConfig({ + disableCaching: false +}); + +Ext.Loader.loadScript({ + + url: function() { + var urlParams = document.URL.split("?"); + var params = Ext.urlDecode(urlParams[urlParams.length - 1]); + + if (!params.lang) { + return "Strings.js"; + } else { + return "Strings-" + params.lang + ".js"; + } + }(), + + onLoad: function() { + + Ext.application({ + name: 'Traccar', + requires: [ + 'Styles', + 'Login' + ], - launch: function() { - Ext.create('Login').show(); + launch: function() { + Ext.create('Login').show(); + } + }); } }); diff --git a/web/Strings-ru.js b/web/Strings-ru.js new file mode 100644 index 000000000..73b3a329f --- /dev/null +++ b/web/Strings-ru.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('Strings', { + singleton: true, + + login_title: 'Логин', + login_user: 'Пользователь', + login_password: 'Пароль', + login_register: 'Регистрация', + login_login: 'Вход', + login_failed: 'Неправильный логин или пароль.', + + device_title: 'Устройства', + device_name: 'Название', + device_identifier: 'Идентификатор', + + map_title: 'Карта' +}); -- cgit v1.2.3