aboutsummaryrefslogtreecommitdiff
path: root/web/locale.js
blob: 0cc7f4b227ba151dbd27e6185e5a9db683238731 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
 * Copyright 2015 Anton Tananaev (anton@traccar.org)
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

var Locale = {};

Locale.languages = {
    'ar': { name: 'العربية', code: 'en' },
    'bg': { name: 'Български', code: 'bg' },
    'cs': { name: 'Čeština', code: 'cs' },
    'de': { name: 'Deutsch', code: 'de' },
    'da': { name: 'Dansk', code: 'da' },
    'el': { name: 'Ελληνικά', code: 'el' },
    'en': { name: 'English', code: 'en' },
    'es': { name: 'Español', code: 'es' },
    'fa': { name: 'فارسی', code: 'fa' },
    'fi': { name: 'Suomi', code: 'fi' },
    'fr': { name: 'Français', code: 'fr' },
    'he': { name: 'עברית', code: 'he' },
    'hi': { name: 'हिन्दी', code: 'en' },
    'hu': { name: 'Magyar', code: 'hu' },
    'id': { name: 'Bahasa Indonesia', code: 'id' },
    'it': { name: 'Italiano', code: 'it' },
    'ka': { name: 'ქართული', code: 'en' },
    'lo': { name: 'ລາວ', code: 'en' },
    'lt': { name: 'Lietuvių', code: 'lt' },
    'ml': { name: 'മലയാളം', code: 'en' },
    'ms': { name: 'بهاس ملايو', code: 'en' },
    'nb': { name: 'Norsk bokmål', code: 'no_NB' },
    'ne': { name: 'नेपाली', code: 'en' },
    'nl': { name: 'Nederlands', code: 'nl' },
    'nn': { name: 'Norsk nynorsk', code: 'no_NN' },
    'pl': { name: 'Polski', code: 'pl' },
    'pt': { name: 'Português', code: 'pt' },
    'pt_BR': { name: 'Português (Brasil)', code: 'pt_BR' },
    'ro': { name: 'Română', code: 'ro' },
    'ru': { name: 'Русский', code: 'ru' },
    'si': { name: 'සිංහල', code: 'en' },
    'sk': { name: 'Slovenčina', code: 'sk' },
    'sl': { name: 'Slovenščina', code: 'sl' },
    'sq': { name: 'Shqipëria', code: 'en' },
    'sr': { name: 'Srpski', code: 'sr' },
    'ta': { name: 'தமிழ்', code: 'en' },
    'th': { name: 'ไทย', code: 'th' },
    'tr': { name: 'Türkçe', code: 'tr' },
    'uk': { name: 'Українська', code: 'ukr' },
    'vi': { name: 'Tiếng Việt', code: 'en' },
    'zh': { name: '中文', code: 'zh_CN' }
};

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 (!(Locale.language in Locale.languages)) {
    Locale.language = 'en'; // default
}

Ext.Ajax.request({
    url: 'l10n/' + Locale.language + '.json',
    callback: function (options, success, response) {
        Strings = Ext.decode(response.responseText);
    }
});

Ext.Loader.loadScript('//cdnjs.cloudflare.com/ajax/libs/extjs/6.0.0/classic/locale/locale-' + Locale.languages[Locale.language].code + '.js');