noVNC language is now sync'ed with MeshCentral.

Ylian Saint-Hilaire committed Jul 1, 2020 at 12:51 UTC 0b7fb139c4f67fd2a51e20e33fc5e02a11be5caa
4 files changed +8 -5
public/novnc/app/localization.js
+3 -1
@@ -20,9 +20,11 @@ export class Localizer {
20 }
21
22 // Configure suitable language based on user preferences
23 - setup(supportedLanguages) {
23 + setup(supportedLanguages, language) {
24 this.language = 'en'; // Default: US English
25
26 + if (language != null) { this.language = language; return; }
27 +
28 /*
29 * Navigator.languages only available in Chrome (32+) and FireFox (32+)
30 * Fall back to navigator.language for other browsers
public/novnc/app/ui.js
+2 -1
@@ -1658,7 +1658,8 @@ const UI = {
1658
1659 // Set up translations
1660 const LINGUAS = ["cs", "de", "el", "es", "ko", "nl", "pl", "ru", "sv", "tr", "zh_CN", "zh_TW"];
1661 -l10n.setup(LINGUAS);
1661 +if (urlargs.l == "zh-chs") { urlargs.l = "zh_CN"; }
1662 +l10n.setup(LINGUAS, urlargs.l);
1663 if (l10n.language === "en" || l10n.dictionary !== undefined) {
1664 UI.prime();
1665 } else {
views/default.handlebars
+1 -1
@@ -2270,7 +2270,7 @@
2270 newWindow.opener = null;
2271 }
2272 } else if (message.tag == 'novnc') {
2273 - var vncurl = window.location.origin + domainUrl + 'novnc/vnc.html?ws=wss%3A%2F%2F' + window.location.host + '%2Fmeshrelay.ashx%3Fauth%3D' + message.cookie + '&show_dot=1' + (urlargs.key?('&key=' + urlargs.key):'');
2273 + var vncurl = window.location.origin + domainUrl + 'novnc/vnc.html?ws=wss%3A%2F%2F' + window.location.host + '%2Fmeshrelay.ashx%3Fauth%3D' + message.cookie + '&show_dot=1' + (urlargs.key?('&key=' + urlargs.key):'') + '&l={{{lang}}}';
2274 var node = getNodeFromId(message.nodeid);
2275 if (node != null) { vncurl += '&name=' + encodeURIComponentEx(node.name); }
2276 var newWindow = window.open(vncurl, 'mcnovnc/' + message.nodeid);
webserver.js
+2 -2
@@ -5823,11 +5823,11 @@ module.exports.CreateWebServer = function (parent, db, args, certificates) {
5823 var fileOptions = obj.renderPages[obj.path.basename(filename)];
5824 if (fileOptions != null) {
5825 for (var i in acceptLanguages) {
5826 - if ((acceptLanguages[i] == 'en') || (acceptLanguages[i].startsWith('en-'))) { break; } // English requested, break out.
5826 + if ((acceptLanguages[i] == 'en') || (acceptLanguages[i].startsWith('en-'))) { args.lang = 'en'; break; } // English requested, break out.
5827 if (fileOptions[acceptLanguages[i]] != null) {
5828 // Found a match. If the file no longer exists, default to English.
5829 obj.fs.exists(fileOptions[acceptLanguages[i]] + '.handlebars', function (exists) {
5830 - if (exists) { args.lang = acceptLanguages[i]; res.render(fileOptions[acceptLanguages[i]], args); } else { res.render(filename, args); }
5830 + if (exists) { args.lang = acceptLanguages[i]; res.render(fileOptions[acceptLanguages[i]], args); } else { args.lang = 'en'; res.render(filename, args); }
5831 });
5832 return;
5833 }