diff options
author | Pierre Ossman <pierre@ossman.eu> | 2016-11-14 22:00:21 +0100 |
---|---|---|
committer | Pierre Ossman <pierre@ossman.eu> | 2016-11-17 20:42:08 +0100 |
commit | 3cdc603aa45850af1e9c25a5a6f28becc6196d2c (patch) | |
tree | 0bc8472879f27e427d268d46db5b83b94ff36606 | |
parent | 45729def6d7d0c4bc8327cf331554680100da3ad (diff) | |
download | novnc-3cdc603aa45850af1e9c25a5a6f28becc6196d2c.tar.gz |
Use gettext .po files for translations
This allows the same workflow as most other projects for translations.
-rw-r--r-- | app/locale/de.js (renamed from app/locale/locale-de-DE.js) | 15 | ||||
-rw-r--r-- | app/locale/el.js | 18 | ||||
-rw-r--r-- | app/locale/locale-el-GR.js | 11 | ||||
-rw-r--r-- | app/locale/locale-en-GB.js | 11 | ||||
-rw-r--r-- | app/locale/nl.js (renamed from app/locale/locale-nl-NL.js) | 15 | ||||
-rw-r--r-- | app/locale/sv.js (renamed from app/locale/locale-sv-SE.js) | 15 | ||||
-rw-r--r-- | app/ui.js | 15 | ||||
-rw-r--r-- | app/webutil.js | 5 | ||||
-rw-r--r-- | core/util.js | 111 | ||||
-rw-r--r-- | package.json | 1 | ||||
-rw-r--r-- | po/Makefile | 29 | ||||
-rw-r--r-- | po/de.po | 58 | ||||
-rw-r--r-- | po/el.po | 57 | ||||
-rw-r--r-- | po/nl.po | 58 | ||||
-rw-r--r-- | po/noVNC.pot | 55 | ||||
-rwxr-xr-x | po/po2js | 56 | ||||
-rw-r--r-- | po/sv.po | 57 | ||||
-rw-r--r-- | tests/test.util.js | 41 | ||||
-rw-r--r-- | vnc_auto.html | 15 |
19 files changed, 534 insertions, 109 deletions
diff --git a/app/locale/locale-de-DE.js b/app/locale/de.js index c9d75aa..6819c48 100644 --- a/app/locale/locale-de-DE.js +++ b/app/locale/de.js @@ -1,11 +1,18 @@ +/* + * Translations for de + * + * This file was autotomatically generated from de.po + * DO NOT EDIT! + */ + Language = { + "Connecting...": "Verbunden...", "Connected (encrypted) to ": "Verbunden mit (verschlüsselt) ", "Connected (unencrypted) to ": "Verbunden mit (unverschlüsselt) ", + "Disconnecting...": "Verbindung trennen...", + "Disconnected": "Verbindung zum Server getrennt", "Must set host and port": "Richten Sie Host und Port ein", - "Disconnect timeout": "Timeout beim trennen", "Password is required": "Passwort ist erforderlich", "Forcing clipping mode since scrollbars aren't supported by IE in fullscreen": "'Clipping-Modus' aktiviert, Scrollbalken in 'IE-Vollbildmodus' werden nicht unterstützt", - "Connecting...": "Verbunden...", - "Disconnecting...": "Verbindung trennen...", - "Disconnected": "Verbindung zum Server getrennt", + "Disconnect timeout": "Timeout beim trennen", }; diff --git a/app/locale/el.js b/app/locale/el.js new file mode 100644 index 0000000..1af2ee6 --- /dev/null +++ b/app/locale/el.js @@ -0,0 +1,18 @@ +/* + * Translations for el + * + * This file was autotomatically generated from el.po + * DO NOT EDIT! + */ + +Language = { + "Connecting...": "Συνδέεται...", + "Connected (encrypted) to ": "Συνδέθηκε (κρυπτογραφημένα) με το ", + "Connected (unencrypted) to ": "Συνδέθηκε (μη κρυπτογραφημένα) με το ", + "Disconnecting...": "Aποσυνδέεται...", + "Disconnected": "Αποσυνδέθηκε", + "Must set host and port": "Πρέπει να οριστεί το όνομα και η πόρτα του διακομιστή", + "Password is required": "Απαιτείται ο κωδικός", + "Forcing clipping mode since scrollbars aren't supported by IE in fullscreen": "Εφαρμογή λειτουργίας αποκοπής αφού δεν υποστηρίζονται οι λωρίδες κύλισης σε πλήρη οθόνη στον IE", + "Disconnect timeout": "Παρέλευση χρονικού ορίου αποσύνδεσης", +}; diff --git a/app/locale/locale-el-GR.js b/app/locale/locale-el-GR.js deleted file mode 100644 index a27fe5a..0000000 --- a/app/locale/locale-el-GR.js +++ /dev/null @@ -1,11 +0,0 @@ -Language = { - "Connected (encrypted) to ": "Συνδέθηκε (κρυπτογραφημένα) με το ", - "Connected (unencrypted) to ": "Συνδέθηκε (μη κρυπτογραφημένα) με το ", - "Must set host and port": "Πρέπει να οριστεί το όνομα και η πόρτα του διακομιστή", - "Disconnect timeout": "Παρέλευση χρονικού ορίου αποσύνδεσης", - "Password is required": "Απαιτείται ο κωδικός", - "Forcing clipping mode since scrollbars aren't supported by IE in fullscreen": "Εφαρμογή λειτουργίας αποκοπής αφού δεν υποστηρίζονται οι λωρίδες κύλισης σε πλήρη οθόνη στον IE", - "Connecting...": "Συνδέεται...", - "Disconnecting...": "Aποσυνδέεται...", - "Disconnected": "Αποσυνδέθηκε", -}; diff --git a/app/locale/locale-en-GB.js b/app/locale/locale-en-GB.js deleted file mode 100644 index 57ce697..0000000 --- a/app/locale/locale-en-GB.js +++ /dev/null @@ -1,11 +0,0 @@ -Language = { - "Connected (encrypted) to ": "Connected (encrypted) to ", - "Connected (unencrypted) to ": "Connected (unencrypted) to ", - "Must set host and port": "Must set host and port", - "Disconnect timeout": "Disconnect timeout", - "Password is required": "Password is required", - "Forcing clipping mode since scrollbars aren't supported by IE in fullscreen": "Forcing clipping mode since scrollbars aren't supported by IE in fullscreen", - "Connecting...": "Connecting...", - "Disconnecting...": "Disconnecting...", - "Disconnected": "Disconnected", -}; diff --git a/app/locale/locale-nl-NL.js b/app/locale/nl.js index 24ad903..cacab30 100644 --- a/app/locale/locale-nl-NL.js +++ b/app/locale/nl.js @@ -1,11 +1,18 @@ +/* + * Translations for nl + * + * This file was autotomatically generated from nl.po + * DO NOT EDIT! + */ + Language = { + "Connecting...": "Verbinden...", "Connected (encrypted) to ": "Verbonden (versleuteld) met ", "Connected (unencrypted) to ": "Verbonden (onversleuteld) met ", + "Disconnecting...": "Verbinding verbreken...", + "Disconnected": "Verbinding verbroken", "Must set host and port": "Host en poort moeten worden ingesteld", - "Disconnect timeout": "Timeout tijdens verbreken van verbinding", "Password is required": "Wachtwoord is vereist", "Forcing clipping mode since scrollbars aren't supported by IE in fullscreen": "''Clipping mode' ingeschakeld, omdat schuifbalken in volledige-scherm-modus in IE niet worden ondersteund", - "Connecting...": "Verbinden...", - "Disconnecting...": "Verbinding verbreken...", - "Disconnected": "Verbinding verbroken", + "Disconnect timeout": "Timeout tijdens verbreken van verbinding", }; diff --git a/app/locale/locale-sv-SE.js b/app/locale/sv.js index eee7f15..b8e0830 100644 --- a/app/locale/locale-sv-SE.js +++ b/app/locale/sv.js @@ -1,11 +1,18 @@ +/* + * Translations for sv + * + * This file was autotomatically generated from sv.po + * DO NOT EDIT! + */ + Language = { + "Connecting...": "Ansluter...", "Connected (encrypted) to ": "Ansluten (krypterat) till ", "Connected (unencrypted) to ": "Ansluten (okrypterat) till ", + "Disconnecting...": "Kopplar ner...", + "Disconnected": "Frånkopplad", "Must set host and port": "Du måste specifiera en host och port", - "Disconnect timeout": "Det tog för lång tid att koppla ner", "Password is required": "Lösenord krävs", "Forcing clipping mode since scrollbars aren't supported by IE in fullscreen": "Tvingar 'Clipping mode' eftersom skrollning inte stödjs av IE i fullskärm", - "Connecting...": "Ansluter...", - "Disconnecting...": "Kopplar ner...", - "Disconnected": "Frånkopplad", + "Disconnect timeout": "Det tog för lång tid att koppla ner", }; @@ -40,13 +40,20 @@ var UI; return false; }); + // Set up translations + var LINGUAS = ["de", "el", "nl", "sv"]; + Util.Localisation.setup(LINGUAS); + if (Util.Localisation.language !== "en") { + WebUtil.load_scripts( + {'app': ["locale/" + Util.Localisation.language + ".js"]}); + } + /* [begin skip-as-module] */ // Load supporting scripts WebUtil.load_scripts( - {'core': [WebUtil.getLanguageFileLocation(), "base64.js", "websock.js", - "des.js", "input/keysymdef.js", "input/xtscancodes.js", - "input/util.js", "input/devices.js", "display.js", - "inflator.js", "rfb.js", "input/keysym.js"]}); + {'core': ["base64.js", "websock.js", "des.js", "input/keysymdef.js", + "input/xtscancodes.js", "input/util.js", "input/devices.js", + "display.js", "inflator.js", "rfb.js", "input/keysym.js"]}); window.onscriptsload = function () { UI.load(); }; /* [end skip-as-module] */ diff --git a/app/webutil.js b/app/webutil.js index ceacd95..90a0a53 100644 --- a/app/webutil.js +++ b/app/webutil.js @@ -372,11 +372,6 @@ WebUtil.releaseCapture = function () { }; -// Get language file location -WebUtil.getLanguageFileLocation = function () { - return '../app/locale/locale-'+Util.Localisation.getLanguageCode()+'.js'; -}; - // Dynamically load scripts without using document.write() // Reference: http://unixpapa.com/js/dyna.html // diff --git a/core/util.js b/core/util.js index 1ec8a3c..8dd99cb 100644 --- a/core/util.js +++ b/core/util.js @@ -368,72 +368,69 @@ Util.Flash = (function () { Util.Localisation = { - defaultLanguage: 'en-GB', - - /* - * Not all languages have been translated - * Some countries prefer a certain language - */ - supportedLanguages: { - 'en': 'en-GB', - 'en-GB': 'en-GB', - 'en-US': 'en-GB', - 'nl': 'nl-NL', - 'nl-NL': 'nl-NL', - 'nl-BE': 'nl-NL', - 'de': 'de-DE', - 'de-DE': 'de-DE', - 'sv-SE': 'sv-SE', - 'sv': 'sv-SE', - 'el': 'el-GR', - 'el-GR': 'el-GR' - }, + // Currently configured language + language: 'en', - // Get language code from browser and verify it - getLanguageCode: function () { - var languageCode = Util.Localisation.getUserPreferredLanguage(); - for (var index = 0; index < languageCode.length; index++) { - var supportedLanguageCode = Util.Localisation.getSupportedLanguageCode(languageCode[index]); - if (supportedLanguageCode) { - return supportedLanguageCode; - } - } + // Configure suitable language based on user preferences + setup: function (supportedLanguages) { + var userLanguages; - return Util.Localisation.defaultLanguage; - }, + Util.Localisation.language = 'en'; // Default: US English - /* - * Retrieve user preferred languages - * Navigator.languages only available in Chrome (32+) and FireFox (32+) - * Fall back to navigator.language for other browsers - */ - getUserPreferredLanguage: function () { + /* + * Navigator.languages only available in Chrome (32+) and FireFox (32+) + * Fall back to navigator.language for other browsers + */ if (typeof window.navigator.languages == 'object') { - return window.navigator.languages; + userLanguages = window.navigator.languages; } else { - var userLang = navigator.language || navigator.userLanguage; - return [userLang]; + userLanguages = [navigator.language || navigator.userLanguage]; } - }, - /* - * Verify if languagecode is supported - * Return the languagecode of the language to use or null if not available - */ - getSupportedLanguageCode: function (languageCode) { - var supportedLanguages = Util.Localisation.supportedLanguages; - - for (var key in supportedLanguages) { - if (supportedLanguages.hasOwnProperty(key)) { - if (key === languageCode) { - // Return the supported language or good alternative - return supportedLanguages[key]; - } + for (var i = 0;i < userLanguages.length;i++) { + var userLang = userLanguages[i]; + userLang = userLang.toLowerCase(); + userLang = userLang.replace("_", "-"); + userLang = userLang.split("-"); + + // Built-in default? + if ((userLang[0] === 'en') && + ((userLang[1] === undefined) || (userLang[1] === 'us'))) { + return; } - } - // LanguageCode not supported - return null; + // First pass: perfect match + for (var j = 0;j < supportedLanguages.length;j++) { + var supLang = supportedLanguages[j]; + supLang = supLang.toLowerCase(); + supLang = supLang.replace("_", "-"); + supLang = supLang.split("-"); + + if (userLang[0] !== supLang[0]) + continue; + if (userLang[1] !== supLang[1]) + continue; + + Util.Localisation.language = supportedLanguages[j]; + return; + } + + // Second pass: fallback + for (var j = 0;j < supportedLanguages.length;j++) { + supLang = supportedLanguages[j]; + supLang = supLang.toLowerCase(); + supLang = supLang.replace("_", "-"); + supLang = supLang.split("-"); + + if (userLang[0] !== supLang[0]) + continue; + if (supLang[1] !== undefined) + continue; + + Util.Localisation.language = supportedLanguages[j]; + return; + } + } }, // Retrieve localised text diff --git a/package.json b/package.json index 6fd6a85..985f064 100644 --- a/package.json +++ b/package.json @@ -48,6 +48,7 @@ "mocha": "^3.1.2", "open": "^0.0.5", "phantomjs-prebuilt": "^2.1.13", + "po2json": "*", "sinon": "^1.17.6", "sinon-chai": "^2.8.0", "spooky": "^0.2.5", diff --git a/po/Makefile b/po/Makefile new file mode 100644 index 0000000..d09d164 --- /dev/null +++ b/po/Makefile @@ -0,0 +1,29 @@ +all: +.PHONY: update-po update-js update-pot + +LINGUAS := de el nl sv + +VERSION := $(shell grep '"version"' ../package.json | cut -d '"' -f 4) + +POFILES := $(addsuffix .po,$(LINGUAS)) +JSFILES := $(addprefix ../app/locale/,$(addsuffix .js,$(LINGUAS))) + +update-po: $(POFILES) +update-js: $(JSFILES) + +%.po: noVNC.pot + msgmerge --update --lang=$* $@ $< +../app/locale/%.js: %.po + ./po2js $< $@ + +update-pot: + xgettext --output=noVNC.pot \ + --copyright-holder="Various Authors" \ + --package-name="noVNC" \ + --package-version="$(VERSION)" \ + --msgid-bugs-address="novnc@googlegroups.com" \ + --add-comments=TRANSLATORS: \ + --sort-by-file \ + ../app/*.js \ + ../core/*.js \ + ../core/input/*.js diff --git a/po/de.po b/po/de.po new file mode 100644 index 0000000..5f15d57 --- /dev/null +++ b/po/de.po @@ -0,0 +1,58 @@ +# German translations for noVNC package +# German translation for noVNC. +# Copyright (C) 2016 Various Authors +# This file is distributed under the same license as the noVNC package. +# Loek Janssen <loekjanssen@gmail.com>, 2016. +# +msgid "" +msgstr "" +"Project-Id-Version: noVNC 0.6.1\n" +"Report-Msgid-Bugs-To: novnc@googlegroups.com\n" +"POT-Creation-Date: 2016-11-15 08:11+0100\n" +"PO-Revision-Date: 2016-11-15 07:51+0100\n" +"Last-Translator: Loek Janssen <loekjanssen@gmail.com>\n" +"Language-Team: none\n" +"Language: de\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: ../app/ui.js:402 +msgid "Connecting..." +msgstr "Verbunden..." + +#: ../app/ui.js:409 +msgid "Connected (encrypted) to " +msgstr "Verbunden mit (verschlüsselt) " + +#: ../app/ui.js:411 +msgid "Connected (unencrypted) to " +msgstr "Verbunden mit (unverschlüsselt) " + +#: ../app/ui.js:416 +msgid "Disconnecting..." +msgstr "Verbindung trennen..." + +#: ../app/ui.js:421 +msgid "Disconnected" +msgstr "Verbindung zum Server getrennt" + +#: ../app/ui.js:1006 ../core/rfb.js:278 +msgid "Must set host and port" +msgstr "Richten Sie Host und Port ein" + +#: ../app/ui.js:1059 +msgid "Password is required" +msgstr "Passwort ist erforderlich" + +#: ../app/ui.js:1272 +msgid "" +"Forcing clipping mode since scrollbars aren't supported by IE in fullscreen" +msgstr "" +"'Clipping-Modus' aktiviert, Scrollbalken in 'IE-Vollbildmodus' werden nicht " +"unterstützt" + +#: ../core/rfb.js:556 +msgid "Disconnect timeout" +msgstr "Timeout beim trennen" diff --git a/po/el.po b/po/el.po new file mode 100644 index 0000000..5dfb36b --- /dev/null +++ b/po/el.po @@ -0,0 +1,57 @@ +# Greek translations for noVNC package. +# Copyright (C) 2016 Various Authors +# This file is distributed under the same license as the noVNC package. +# Giannis Kosmas <kosmasgiannis@gmail.com>, 2016. +# +msgid "" +msgstr "" +"Project-Id-Version: noVNC 0.6.1\n" +"Report-Msgid-Bugs-To: novnc@googlegroups.com\n" +"POT-Creation-Date: 2016-11-15 08:11+0100\n" +"PO-Revision-Date: 2016-11-15 07:51+0100\n" +"Last-Translator: Giannis Kosmas <kosmasgiannis@gmail.com>\n" +"Language-Team: none\n" +"Language: el\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: ../app/ui.js:402 +msgid "Connecting..." +msgstr "Συνδέεται..." + +#: ../app/ui.js:409 +msgid "Connected (encrypted) to " +msgstr "Συνδέθηκε (κρυπτογραφημένα) με το " + +#: ../app/ui.js:411 +msgid "Connected (unencrypted) to " +msgstr "Συνδέθηκε (μη κρυπτογραφημένα) με το " + +#: ../app/ui.js:416 +msgid "Disconnecting..." +msgstr "Aποσυνδέεται..." + +#: ../app/ui.js:421 +msgid "Disconnected" +msgstr "Αποσυνδέθηκε" + +#: ../app/ui.js:1006 ../core/rfb.js:278 +msgid "Must set host and port" +msgstr "Πρέπει να οριστεί το όνομα και η πόρτα του διακομιστή" + +#: ../app/ui.js:1059 +msgid "Password is required" +msgstr "Απαιτείται ο κωδικός" + +#: ../app/ui.js:1272 +msgid "" +"Forcing clipping mode since scrollbars aren't supported by IE in fullscreen" +msgstr "" +"Εφαρμογή λειτουργίας αποκοπής αφού δεν υποστηρίζονται οι λωρίδες κύλισης σε " +"πλήρη οθόνη στον IE" + +#: ../core/rfb.js:556 +msgid "Disconnect timeout" +msgstr "Παρέλευση χρονικού ορίου αποσύνδεσης" diff --git a/po/nl.po b/po/nl.po new file mode 100644 index 0000000..8a0bf74 --- /dev/null +++ b/po/nl.po @@ -0,0 +1,58 @@ +# Dutch translations for noVNC package +# Nederlandse vertalingen voor het pakket noVNC. +# Copyright (C) 2016 Various Authors +# This file is distributed under the same license as the noVNC package. +# Loek Janssen <loekjanssen@gmail.com>, 2016. +# +msgid "" +msgstr "" +"Project-Id-Version: noVNC 0.6.1\n" +"Report-Msgid-Bugs-To: novnc@googlegroups.com\n" +"POT-Creation-Date: 2016-11-15 08:11+0100\n" +"PO-Revision-Date: 2016-11-15 07:51+0100\n" +"Last-Translator: Loek Janssen <loekjanssen@gmail.com>\n" +"Language-Team: none\n" +"Language: nl\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: ../app/ui.js:402 +msgid "Connecting..." +msgstr "Verbinden..." + +#: ../app/ui.js:409 +msgid "Connected (encrypted) to " +msgstr "Verbonden (versleuteld) met " + +#: ../app/ui.js:411 +msgid "Connected (unencrypted) to " +msgstr "Verbonden (onversleuteld) met " + +#: ../app/ui.js:416 +msgid "Disconnecting..." +msgstr "Verbinding verbreken..." + +#: ../app/ui.js:421 +msgid "Disconnected" +msgstr "Verbinding verbroken" + +#: ../app/ui.js:1006 ../core/rfb.js:278 +msgid "Must set host and port" +msgstr "Host en poort moeten worden ingesteld" + +#: ../app/ui.js:1059 +msgid "Password is required" +msgstr "Wachtwoord is vereist" + +#: ../app/ui.js:1272 +msgid "" +"Forcing clipping mode since scrollbars aren't supported by IE in fullscreen" +msgstr "" +"''Clipping mode' ingeschakeld, omdat schuifbalken in volledige-scherm-modus " +"in IE niet worden ondersteund" + +#: ../core/rfb.js:556 +msgid "Disconnect timeout" +msgstr "Timeout tijdens verbreken van verbinding" diff --git a/po/noVNC.pot b/po/noVNC.pot new file mode 100644 index 0000000..ec6f960 --- /dev/null +++ b/po/noVNC.pot @@ -0,0 +1,55 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Various Authors +# This file is distributed under the same license as the noVNC package. +# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: noVNC 0.6.1\n" +"Report-Msgid-Bugs-To: novnc@googlegroups.com\n" +"POT-Creation-Date: 2016-11-15 08:11+0100\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" +"Language-Team: LANGUAGE <LL@li.org>\n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: ../app/ui.js:402 +msgid "Connecting..." +msgstr "" + +#: ../app/ui.js:409 +msgid "Connected (encrypted) to " +msgstr "" + +#: ../app/ui.js:411 +msgid "Connected (unencrypted) to " +msgstr "" + +#: ../app/ui.js:416 +msgid "Disconnecting..." +msgstr "" + +#: ../app/ui.js:421 +msgid "Disconnected" +msgstr "" + +#: ../app/ui.js:1006 ../core/rfb.js:278 +msgid "Must set host and port" +msgstr "" + +#: ../app/ui.js:1059 +msgid "Password is required" +msgstr "" + +#: ../app/ui.js:1272 +msgid "" +"Forcing clipping mode since scrollbars aren't supported by IE in fullscreen" +msgstr "" + +#: ../core/rfb.js:556 +msgid "Disconnect timeout" +msgstr "" diff --git a/po/po2js b/po/po2js new file mode 100755 index 0000000..972f0b2 --- /dev/null +++ b/po/po2js @@ -0,0 +1,56 @@ +#!/usr/bin/env node +/* + * ps2js: gettext .po to noVNC .js converter + * Copyright (C) 2016 Pierre Ossman + * + * 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 getopt = require('node-getopt'); +var fs = require('fs'); +var po2json = require("po2json"); + +opt = getopt.create([ + ['h' , 'help' , 'display this help'], +]).bindHelp().parseSystem(); + +if (opt.argv.length != 2) { + console.error("Incorrect number of arguments given"); + process.exit(1); +} + +var data = po2json.parseFileSync(opt.argv[0]); + +var output = +"/*\n" + +" * Translations for " + data[""]["language"] + "\n" + +" *\n" + +" * This file was autotomatically generated from " + opt.argv[0] + "\n" + +" * DO NOT EDIT!\n" + +" */\n" + +"\n" + +"Language = {\n"; + +for (msgid in data) { + if (msgid === "") + continue; + + msgstr = data[msgid][1]; + output += " " + JSON.stringify(msgid) + ": " + + JSON.stringify(msgstr) + ",\n"; +} + +output += "};\n"; + +fs.writeFileSync(opt.argv[1], output); diff --git a/po/sv.po b/po/sv.po new file mode 100644 index 0000000..d42b43e --- /dev/null +++ b/po/sv.po @@ -0,0 +1,57 @@ +# Swedish translations for noVNC package +# Svenska översättningar för paket noVNC. +# Copyright (C) 2016 Various Authors +# This file is distributed under the same license as the noVNC package. +# Samuel Mannehed <samuel@cendio.se>, 2016. +# +msgid "" +msgstr "" +"Project-Id-Version: noVNC 0.6.1\n" +"Report-Msgid-Bugs-To: novnc@googlegroups.com\n" +"POT-Creation-Date: 2016-11-15 08:11+0100\n" +"PO-Revision-Date: 2016-11-15 07:51+0100\n" +"Last-Translator: Samuel Mannehed <samuel@cendio.se>\n" +"Language-Team: none\n" +"Language: sv\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: ../app/ui.js:402 +msgid "Connecting..." +msgstr "Ansluter..." + +#: ../app/ui.js:409 +msgid "Connected (encrypted) to " +msgstr "Ansluten (krypterat) till " + +#: ../app/ui.js:411 +msgid "Connected (unencrypted) to " +msgstr "Ansluten (okrypterat) till " + +#: ../app/ui.js:416 +msgid "Disconnecting..." +msgstr "Kopplar ner..." + +#: ../app/ui.js:421 +msgid "Disconnected" +msgstr "Frånkopplad" + +#: ../app/ui.js:1006 ../core/rfb.js:278 +msgid "Must set host and port" +msgstr "Du måste specifiera en host och port" + +#: ../app/ui.js:1059 +msgid "Password is required" +msgstr "Lösenord krävs" + +#: ../app/ui.js:1272 +msgid "" +"Forcing clipping mode since scrollbars aren't supported by IE in fullscreen" +msgstr "" +"Tvingar 'Clipping mode' eftersom skrollning inte stödjs av IE i fullskärm" + +#: ../core/rfb.js:556 +msgid "Disconnect timeout" +msgstr "Det tog för lång tid att koppla ner" diff --git a/tests/test.util.js b/tests/test.util.js index c903c74..fbce2ef 100644 --- a/tests/test.util.js +++ b/tests/test.util.js @@ -56,6 +56,47 @@ describe('Utils', function() { }); }); + describe('language selection', function () { + it('should use English by default', function() { + expect(Util.Localisation.language).to.equal('en'); + }); + it('should use English if no user language matches', function() { + window.navigator.languages = ["nl", "de"]; + Util.Localisation.setup(["es", "fr"]); + expect(Util.Localisation.language).to.equal('en'); + }); + it('should use the most preferred user language', function() { + window.navigator.languages = ["nl", "de", "fr"]; + Util.Localisation.setup(["es", "fr", "de"]); + expect(Util.Localisation.language).to.equal('de'); + }); + it('should prefer sub-languages languages', function() { + window.navigator.languages = ["pt-BR"]; + Util.Localisation.setup(["pt", "pt-BR"]); + expect(Util.Localisation.language).to.equal('pt-BR'); + }); + it('should fall back to language "parents"', function() { + window.navigator.languages = ["pt-BR"]; + Util.Localisation.setup(["fr", "pt", "de"]); + expect(Util.Localisation.language).to.equal('pt'); + }); + it('should not use specific language when user asks for a generic language', function() { + window.navigator.languages = ["pt", "de"]; + Util.Localisation.setup(["fr", "pt-BR", "de"]); + expect(Util.Localisation.language).to.equal('de'); + }); + it('should handle underscore as a separator', function() { + window.navigator.languages = ["pt-BR"]; + Util.Localisation.setup(["pt_BR"]); + expect(Util.Localisation.language).to.equal('pt_BR'); + }); + it('should handle difference in case', function() { + window.navigator.languages = ["pt-br"]; + Util.Localisation.setup(["pt-BR"]); + expect(Util.Localisation.language).to.equal('pt-BR'); + }); + }); + // TODO(directxman12): test the conf_default and conf_defaults methods // TODO(directxman12): test decodeUTF8 // TODO(directxman12): test the event methods (addEvent, removeEvent, stopEvent) diff --git a/vnc_auto.html b/vnc_auto.html index ea1ca7b..e86ae5d 100644 --- a/vnc_auto.html +++ b/vnc_auto.html @@ -81,8 +81,7 @@ WebUtil.load_scripts({ 'core': ["base64.js", "websock.js", "des.js", "input/keysymdef.js", "input/xtscancodes.js", "input/util.js", "input/devices.js", - "display.js", "inflator.js", "rfb.js", "input/keysym.js"], - 'app': [WebUtil.getLanguageFileLocation(), "webutil.js"]}); + "display.js", "inflator.js", "rfb.js", "input/keysym.js"]}); var rfb; var resizeTimeout; @@ -153,24 +152,22 @@ var cad = document.getElementById('sendCtrlAltDelButton'); switch (state) { case 'connecting': - status(Util.Localisation.get("Connecting"), "normal"); + status("Connecting", "normal"); break; case 'connected': if (rfb && rfb.get_encrypt()) { - status(Util.Localisation. - get("Connected (encrypted) to ") + + status("Connected (encrypted) to " + desktopName, "normal"); } else { - status(Util.Localisation. - get("Connected (unencrypted) to ") + + status("Connected (unencrypted) to " + desktopName, "normal"); } break; case 'disconnecting': - status(Util.Localisation.get("Disconnecting"), "normal"); + status("Disconnecting", "normal"); break; case 'disconnected': - status(Util.Localisation.get("Disconnected"), "normal"); + status("Disconnected", "normal"); break; default: status(state, "warn"); |