From cf5ed56c943599c092a91933b45471c4c0e5d579 Mon Sep 17 00:00:00 2001 From: Ruben Pollan Date: Fri, 10 Jul 2020 11:04:49 +0200 Subject: Add support for internationalization - Resolves: #243 --- .gitignore | 1 + Makefile | 21 ++---- bitmask.pro | 5 ++ build.sh | 1 + gui/i18n/base.ts | 172 ++++++++++++++++++++++++++++++++++++++++++ gui/i18n/main_ar.ts | 172 ++++++++++++++++++++++++++++++++++++++++++ gui/i18n/main_es.ts | 172 ++++++++++++++++++++++++++++++++++++++++++ gui/i18n/main_es_ES.ts | 172 ++++++++++++++++++++++++++++++++++++++++++ gui/i18n/main_nl.ts | 172 ++++++++++++++++++++++++++++++++++++++++++ gui/i18n/main_pl.ts | 172 ++++++++++++++++++++++++++++++++++++++++++ gui/i18n/main_pt_BR.ts | 172 ++++++++++++++++++++++++++++++++++++++++++ gui/main.cpp | 5 ++ gui/qml/AboutDialog.qml | 9 ++- gui/qml/DonateDialog.qml | 2 + gui/qml/LoginConfirmation.qml | 4 +- gui/qml/LoginDialog.qml | 8 +- gui/qml/main.qml | 16 ++-- tools/transifex/Makefile | 8 -- tools/transifex/main.go | 124 ------------------------------ tools/transifex/messages.json | 28 ------- 20 files changed, 1247 insertions(+), 189 deletions(-) create mode 100644 gui/i18n/base.ts create mode 100644 gui/i18n/main_ar.ts create mode 100644 gui/i18n/main_es.ts create mode 100644 gui/i18n/main_es_ES.ts create mode 100644 gui/i18n/main_nl.ts create mode 100644 gui/i18n/main_pl.ts create mode 100644 gui/i18n/main_pt_BR.ts delete mode 100644 tools/transifex/Makefile delete mode 100644 tools/transifex/main.go delete mode 100644 tools/transifex/messages.json diff --git a/.gitignore b/.gitignore index 5cb4e9e..7c8e96b 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ cmd/bitmask-vpn/bitmask-vpn cmd/bitmask-helper/bitmask-helper /bitmask-connect cmd/bitmask-connect/bitmask-connect +gui/i18n/*.qm locales/*/out.gotext.json tools/transifex/transifex diff --git a/Makefile b/Makefile index 7d284b4..4722146 100644 --- a/Makefile +++ b/Makefile @@ -241,23 +241,12 @@ icon: @make -C icon -LANGS ?= $(foreach path,$(wildcard locales/*),$(patsubst locales/%,%,$(path))) -empty := -space := $(empty) $(empty) -lang_list := $(subst $(space),,$(foreach lang,$(LANGS),$(lang),)) +LANGS ?= $(foreach path,$(wildcard gui/i18n/main_*.ts),$(patsubst gui/i18n/main_%.ts,%,$(path))) -locales: $(foreach lang,$(LANGS),get_$(lang)) cmd/bitmask-vpn/catalog.go +locales: $(foreach lang,$(LANGS),get_$(lang)) generate_locales: - @gotext update -lang=$(lang_list) ./pkg/systray ./pkg/bitmask - @make -C tools/transifex + @lupdate bitmask.pro -locales/%/out.gotext.json: pkg/systray/systray.go pkg/systray/notificator.go pkg/bitmask/standalone.go - @gotext update -lang=$* ./pkg/systray ./pkg/bitmask - -cmd/bitmask-vpn/catalog.go: $(foreach lang,$(LANGS),locales/$(lang)/messages.gotext.json) - @gotext update -lang=$(lang_list) -out cmd/bitmask-vpn/catalog.go ./pkg/systray ./pkg/bitmask - -get_%: locales/%/out.gotext.json - @make -C tools/transifex build - @curl -L -X GET --user "api:${API_TOKEN}" "https://www.transifex.com/api/2/project/bitmask/resource/RiseupVPN/translation/${subst -,_,$*}/?file" | tools/transifex/transifex t2g locales/$*/ +get_%: + @curl -L -X GET --user "api:${API_TOKEN}" "https://www.transifex.com/api/2/project/bitmask/resource/riseupvpn-test/translation/${subst -,_,$*}/?file" > gui/i18n/main_$*.ts diff --git a/bitmask.pro b/bitmask.pro index 7a29483..fcedd75 100644 --- a/bitmask.pro +++ b/bitmask.pro @@ -47,3 +47,8 @@ Debug:UI_DIR = debug/.ui DISTFILES += \ README.md + +CONFIG += lrelease embed_translations + +TRANSLATIONS += $$files(gui/i18n/*.ts, true) +RESOURCES += $$files(gui/i18n/*.qm, true) diff --git a/build.sh b/build.sh index c7085a6..94f77b3 100755 --- a/build.sh +++ b/build.sh @@ -51,6 +51,7 @@ function buildQmake { echo "[+] Building BitmaskVPN" +lrelease bitmask.pro buildGoLib buildQmake make -C qtbuild clean diff --git a/gui/i18n/base.ts b/gui/i18n/base.ts new file mode 100644 index 0000000..9110c36 --- /dev/null +++ b/gui/i18n/base.ts @@ -0,0 +1,172 @@ + + + + + AboutDialog + + + About + + + + + <p>%1 is an easy, fast, and secure VPN service from %2. %1 does not require a user account, keep logs, or track you in any way.</p> <p>This service is paid for entirely by donations from users like you. <a href="%3">Please donate</a>.</p> <p>By using this application, you agree to the <a href="%4">Terms of Service</a>. This service is provided as-is, without any warranty, and is intended for people who work to make the world a better place.</p> + about dialog %1 -> application name %2 -> provider name %3 -> donation URL %4 -> TOS URL + + + + + %1 version: %2 + %1 -> application name %2 -> version string + + + + + DonateDialog + + + Donate + + + + + The %1 service is expensive to run. Because we don't want to store personal information about you, there are no accounts or billing for this service. But if you want the service to continue, donate at least $5 each month. + +Do you want to donate now? + donate dialog %1 -> application name + + + + + LoginDialog + + + Login + + + + + Log in with your library credentials + + + + + patron id + + + + + password + + + + + main + + + Could not find helpers. Check your installation + + + + + Could not find polkit agent. + + + + + %1 off + %1 -> application name + + + + + %1 on + %1 -> application name + + + + + Connecting to %1 + %1 -> application name + + + + + Stopping %1 + %1 -> application name + + + + + %1 blocking internet + %1 -> application name + + + + + + Checking status... + + + + + Reconnect + + + + + Turn on + + + + + Cancel + + + + + Turn off + + + + + Help... + + + + + Donate... + + + + + About... + + + + + Quit + + + + + Error starting VPN + + + + + Missing authentication agent + + + + + Could not find a polkit authentication agent. Please run one and try again. + + + + + Initialization Error + + + + diff --git a/gui/i18n/main_ar.ts b/gui/i18n/main_ar.ts new file mode 100644 index 0000000..5a8869a --- /dev/null +++ b/gui/i18n/main_ar.ts @@ -0,0 +1,172 @@ + + + + + AboutDialog + + + About + حول + + + + <p>%1 is an easy, fast, and secure VPN service from %2. %1 does not require a user account, keep logs, or track you in any way.</p> <p>This service is paid for entirely by donations from users like you. <a href="%3">Please donate</a>.</p> <p>By using this application, you agree to the <a href="%4">Terms of Service</a>. This service is provided as-is, without any warranty, and is intended for people who work to make the world a better place.</p> + about dialog %1 -> application name %2 -> provider name %3 -> donation URL %4 -> TOS URL + + + + + %1 version: %2 + %1 -> application name %2 -> version string + + + + + DonateDialog + + + Donate + تبرَّع + + + + The %1 service is expensive to run. Because we don't want to store personal information about you, there are no accounts or billing for this service. But if you want the service to continue, donate at least $5 each month. + +Do you want to donate now? + donate dialog %1 -> application name + + + + + LoginDialog + + + Login + تسجيل الدخول + + + + Log in with your library credentials + + + + + patron id + + + + + password + + + + + main + + + Could not find helpers. Check your installation + + + + + Could not find polkit agent. + + + + + %1 off + %1 -> application name + + + + + %1 on + %1 -> application name + + + + + Connecting to %1 + %1 -> application name + + + + + Stopping %1 + %1 -> application name + + + + + %1 blocking internet + %1 -> application name + + + + + + Checking status... + جارى التحقق من الوضع... + + + + Reconnect + إعادة الاتصال + + + + Turn on + تشغيل + + + + Cancel + إلغاء + + + + Turn off + إغلاق + + + + Help... + المساعدة... + + + + Donate... + تبرع... + + + + About... + عن الخدمة... + + + + Quit + خروج + + + + Error starting VPN + حدث خطأ فى تشغيل VPN + + + + Missing authentication agent + أداة الدخول للحساب مفقودة + + + + Could not find a polkit authentication agent. Please run one and try again. + لم يجد البرنامج أداة الدخول (polkit). من فضلك شغل واحدة وحاول ثانية. + + + + Initialization Error + + + + diff --git a/gui/i18n/main_es.ts b/gui/i18n/main_es.ts new file mode 100644 index 0000000..48e98ef --- /dev/null +++ b/gui/i18n/main_es.ts @@ -0,0 +1,172 @@ + + + + + AboutDialog + + + About + Acerca de + + + + <p>%1 is an easy, fast, and secure VPN service from %2. %1 does not require a user account, keep logs, or track you in any way.</p> <p>This service is paid for entirely by donations from users like you. <a href="%3">Please donate</a>.</p> <p>By using this application, you agree to the <a href="%4">Terms of Service</a>. This service is provided as-is, without any warranty, and is intended for people who work to make the world a better place.</p> + about dialog %1 -> application name %2 -> provider name %3 -> donation URL %4 -> TOS URL + + + + + %1 version: %2 + %1 -> application name %2 -> version string + + + + + DonateDialog + + + Donate + Dona + + + + The %1 service is expensive to run. Because we don't want to store personal information about you, there are no accounts or billing for this service. But if you want the service to continue, donate at least $5 each month. + +Do you want to donate now? + donate dialog %1 -> application name + + + + + LoginDialog + + + Login + Acceder + + + + Log in with your library credentials + + + + + patron id + + + + + password + + + + + main + + + Could not find helpers. Check your installation + + + + + Could not find polkit agent. + + + + + %1 off + %1 -> application name + + + + + %1 on + %1 -> application name + + + + + Connecting to %1 + %1 -> application name + + + + + Stopping %1 + %1 -> application name + + + + + %1 blocking internet + %1 -> application name + + + + + + Checking status... + Comprobando el estado... + + + + Reconnect + Volver a conectar + + + + Turn on + Encender + + + + Cancel + Cancelar + + + + Turn off + Apagar + + + + Help... + Ayuda... + + + + Donate... + Dona... + + + + About... + Acerca de... + + + + Quit + Cerrar + + + + Error starting VPN + Error al iniciar la VPN + + + + Missing authentication agent + Falta un agente de autenticación + + + + Could not find a polkit authentication agent. Please run one and try again. + No se pudo encontrar ningún agente de autenticacion de polkit. Por favor lanza uno y prueba de nuevo. + + + + Initialization Error + + + + diff --git a/gui/i18n/main_es_ES.ts b/gui/i18n/main_es_ES.ts new file mode 100644 index 0000000..48ca2c2 --- /dev/null +++ b/gui/i18n/main_es_ES.ts @@ -0,0 +1,172 @@ + + + + + AboutDialog + + + About + Acerca de + + + + <p>%1 is an easy, fast, and secure VPN service from %2. %1 does not require a user account, keep logs, or track you in any way.</p> <p>This service is paid for entirely by donations from users like you. <a href="%3">Please donate</a>.</p> <p>By using this application, you agree to the <a href="%4">Terms of Service</a>. This service is provided as-is, without any warranty, and is intended for people who work to make the world a better place.</p> + about dialog %1 -> application name %2 -> provider name %3 -> donation URL %4 -> TOS URL + + + + + %1 version: %2 + %1 -> application name %2 -> version string + + + + + DonateDialog + + + Donate + Donar + + + + The %1 service is expensive to run. Because we don't want to store personal information about you, there are no accounts or billing for this service. But if you want the service to continue, donate at least $5 each month. + +Do you want to donate now? + donate dialog %1 -> application name + + + + + LoginDialog + + + Login + Iniciar Sesión + + + + Log in with your library credentials + + + + + patron id + + + + + password + + + + + main + + + Could not find helpers. Check your installation + + + + + Could not find polkit agent. + + + + + %1 off + %1 -> application name + + + + + %1 on + %1 -> application name + + + + + Connecting to %1 + %1 -> application name + + + + + Stopping %1 + %1 -> application name + + + + + %1 blocking internet + %1 -> application name + + + + + + Checking status... + Comprobando estado... + + + + Reconnect + Reconectar + + + + Turn on + Activar + + + + Cancel + Cancelar + + + + Turn off + Desactivar + + + + Help... + Ayuda... + + + + Donate... + Donar... + + + + About... + Acerca de... + + + + Quit + Salir + + + + Error starting VPN + Error iniciando VPN + + + + Missing authentication agent + Falta agente de autenticación + + + + Could not find a polkit authentication agent. Please run one and try again. + No se pudo encontrar un agente de autenticación polkit. Por favor corre uno e intenta de nuevo. + + + + Initialization Error + + + + diff --git a/gui/i18n/main_nl.ts b/gui/i18n/main_nl.ts new file mode 100644 index 0000000..4709f71 --- /dev/null +++ b/gui/i18n/main_nl.ts @@ -0,0 +1,172 @@ + + + + + AboutDialog + + + About + Over + + + + <p>%1 is an easy, fast, and secure VPN service from %2. %1 does not require a user account, keep logs, or track you in any way.</p> <p>This service is paid for entirely by donations from users like you. <a href="%3">Please donate</a>.</p> <p>By using this application, you agree to the <a href="%4">Terms of Service</a>. This service is provided as-is, without any warranty, and is intended for people who work to make the world a better place.</p> + about dialog %1 -> application name %2 -> provider name %3 -> donation URL %4 -> TOS URL + + + + + %1 version: %2 + %1 -> application name %2 -> version string + + + + + DonateDialog + + + Donate + Doneren + + + + The %1 service is expensive to run. Because we don't want to store personal information about you, there are no accounts or billing for this service. But if you want the service to continue, donate at least $5 each month. + +Do you want to donate now? + donate dialog %1 -> application name + + + + + LoginDialog + + + Login + Inloggen + + + + Log in with your library credentials + + + + + patron id + + + + + password + + + + + main + + + Could not find helpers. Check your installation + + + + + Could not find polkit agent. + + + + + %1 off + %1 -> application name + + + + + %1 on + %1 -> application name + + + + + Connecting to %1 + %1 -> application name + + + + + Stopping %1 + %1 -> application name + + + + + %1 blocking internet + %1 -> application name + + + + + + Checking status... + Status controleren... + + + + Reconnect + Opnieuw verbinden + + + + Turn on + Inschakelen + + + + Cancel + Annuleren + + + + Turn off + Uitschakelen + + + + Help... + Hulp... + + + + Donate... + Doneren... + + + + About... + Over... + + + + Quit + Stoppen + + + + Error starting VPN + Fout bij het opstarten van de VPN + + + + Missing authentication agent + Authenticatieagent ontbreekt + + + + Could not find a polkit authentication agent. Please run one and try again. + Kan geen polkit authenticatieagent vinden. Voer er een uit en probeer opnieuw. + + + + Initialization Error + + + + diff --git a/gui/i18n/main_pl.ts b/gui/i18n/main_pl.ts new file mode 100644 index 0000000..768b383 --- /dev/null +++ b/gui/i18n/main_pl.ts @@ -0,0 +1,172 @@ + + + + + AboutDialog + + + About + O programie... + + + + <p>%1 is an easy, fast, and secure VPN service from %2. %1 does not require a user account, keep logs, or track you in any way.</p> <p>This service is paid for entirely by donations from users like you. <a href="%3">Please donate</a>.</p> <p>By using this application, you agree to the <a href="%4">Terms of Service</a>. This service is provided as-is, without any warranty, and is intended for people who work to make the world a better place.</p> + about dialog %1 -> application name %2 -> provider name %3 -> donation URL %4 -> TOS URL + + + + + %1 version: %2 + %1 -> application name %2 -> version string + + + + + DonateDialog + + + Donate + Darowizna + + + + The %1 service is expensive to run. Because we don't want to store personal information about you, there are no accounts or billing for this service. But if you want the service to continue, donate at least $5 each month. + +Do you want to donate now? + donate dialog %1 -> application name + + + + + LoginDialog + + + Login + Login + + + + Log in with your library credentials + + + + + patron id + + + + + password + + + + + main + + + Could not find helpers. Check your installation + + + + + Could not find polkit agent. + + + + + %1 off + %1 -> application name + + + + + %1 on + %1 -> application name + + + + + Connecting to %1 + %1 -> application name + + + + + Stopping %1 + %1 -> application name + + + + + %1 blocking internet + %1 -> application name + + + + + + Checking status... + Sprawdzanie statusu + + + + Reconnect + Połącz ponownie + + + + Turn on + Włącz + + + + Cancel + Anuluj + + + + Turn off + Wyłącz + + + + Help... + Pomoc... + + + + Donate... + Wesprzyj... + + + + About... + O programie... + + + + Quit + Zamknij + + + + Error starting VPN + Błąd przy uruchamianiu VPN'a + + + + Missing authentication agent + Brakujący agent autoryzacji + + + + Could not find a polkit authentication agent. Please run one and try again. + Nie znaleziono agenta autentykacji polkit. Proszę uruchom go i spróbuj ponownie. + + + + Initialization Error + + + + diff --git a/gui/i18n/main_pt_BR.ts b/gui/i18n/main_pt_BR.ts new file mode 100644 index 0000000..ad04d47 --- /dev/null +++ b/gui/i18n/main_pt_BR.ts @@ -0,0 +1,172 @@ + + + + + AboutDialog + + + About + Sobre + + + + <p>%1 is an easy, fast, and secure VPN service from %2. %1 does not require a user account, keep logs, or track you in any way.</p> <p>This service is paid for entirely by donations from users like you. <a href="%3">Please donate</a>.</p> <p>By using this application, you agree to the <a href="%4">Terms of Service</a>. This service is provided as-is, without any warranty, and is intended for people who work to make the world a better place.</p> + about dialog %1 -> application name %2 -> provider name %3 -> donation URL %4 -> TOS URL + + + + + %1 version: %2 + %1 -> application name %2 -> version string + + + + + DonateDialog + + + Donate + Fazer uma doação + + + + The %1 service is expensive to run. Because we don't want to store personal information about you, there are no accounts or billing for this service. But if you want the service to continue, donate at least $5 each month. + +Do you want to donate now? + donate dialog %1 -> application name + + + + + LoginDialog + + + Login + Conectar + + + + Log in with your library credentials + + + + + patron id + + + + + password + + + + + main + + + Could not find helpers. Check your installation + + + + + Could not find polkit agent. + + + + + %1 off + %1 -> application name + + + + + %1 on + %1 -> application name + + + + + Connecting to %1 + %1 -> application name + + + + + Stopping %1 + %1 -> application name + + + + + %1 blocking internet + %1 -> application name + + + + + + Checking status... + Verificando estado... + + + + Reconnect + Reconectar + + + + Turn on + Ligar + + + + Cancel + Cancelar + + + + Turn off + Desligar + + + + Help... + Ajuda... + + + + Donate... + Fazer uma doação... + + + + About... + Sobre... + + + + Quit + Sair + + + + Error starting VPN + Erro ao iniciar a VPN + + + + Missing authentication agent + Um agente de autenticação está faltando + + + + Could not find a polkit authentication agent. Please run one and try again. + Não foi possível encontrar um agente de autenticação polkit. Por favor, execute um agente e tente novamente. + + + + Initialization Error + + + + diff --git a/gui/main.cpp b/gui/main.cpp index 670e664..73d55cc 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include #include #include @@ -56,6 +57,10 @@ int main(int argc, char **argv) { if (!QSystemTrayIcon::isSystemTrayAvailable()) { qDebug() << "No systray icon available. Things might not work for now, sorry..."; } + + QTranslator translator; + translator.load(QLocale(), QLatin1String("main"), QLatin1String("_"), QLatin1String(":/i18n")); + app.installTranslator(&translator); app.setQuitOnLastWindowClosed(false); QQmlApplicationEngine engine; diff --git a/gui/qml/AboutDialog.qml b/gui/qml/AboutDialog.qml index 98cacdc..68e76d3 100644 --- a/gui/qml/AboutDialog.qml +++ b/gui/qml/AboutDialog.qml @@ -11,6 +11,11 @@ MessageDialog { var _provider = ctx ? ctx.provider : "unknown" var _donateURL= ctx ? ctx.donateURL : "..." var _tosURL = ctx ? ctx.tosURL : "..." + //: about dialog + //: %1 -> application name + //: %2 -> provider name + //: %3 -> donation URL + //: %4 -> TOS URL var _txt = qsTr( "

%1 is an easy, fast, and secure VPN service from %2. %1 does not require a user account, keep logs, or track you in any way.

This service is paid for entirely by donations from users like you. Please donate.

By using this application, you agree to the Terms of Service. This service is provided as-is, without any warranty, and is intended for people who work to make the world a better place.

").arg(_name).arg(_provider).arg(_donateURL).arg(_tosURL) return _txt @@ -19,7 +24,9 @@ MessageDialog { function getVersion() { var _name = ctx ? ctx.appName : "vpn" var _ver = ctx ? ctx.version : "unknown" - var _txt = "%1 version: %2".arg(_name).arg(_ver) + //: %1 -> application name + //: %2 -> version string + var _txt = qsTr("%1 version: %2").arg(_name).arg(_ver) return _txt } } diff --git a/gui/qml/DonateDialog.qml b/gui/qml/DonateDialog.qml index de7ab5b..afbd57b 100644 --- a/gui/qml/DonateDialog.qml +++ b/gui/qml/DonateDialog.qml @@ -9,6 +9,8 @@ MessageDialog { function getText() { var _name = ctx ? ctx.appName : "vpn" + //: donate dialog + //: %1 -> application name var _txt = qsTr( "The %1 service is expensive to run. Because we don't want to store personal information about you, there are no accounts or billing for this service. But if you want the service to continue, donate at least $5 each month.\n\nDo you want to donate now?").arg(_name) return _txt diff --git a/gui/qml/LoginConfirmation.qml b/gui/qml/LoginConfirmation.qml index 476cdad..618b870 100644 --- a/gui/qml/LoginConfirmation.qml +++ b/gui/qml/LoginConfirmation.qml @@ -4,8 +4,8 @@ import QtQuick.Controls 1.4 Dialog { standardButtons: StandardButton.Ok - title: "Login Success" - text: "You are now logged in, connecting now" + title: qsTr("Login Success") + text: qsTr("You are now logged in, connecting now") visible: ctxSystray.loginConfirmationDialog == true } diff --git a/gui/qml/LoginDialog.qml b/gui/qml/LoginDialog.qml index fbe5ce1..0c0f18e 100644 --- a/gui/qml/LoginDialog.qml +++ b/gui/qml/LoginDialog.qml @@ -4,19 +4,19 @@ import QtQuick.Controls 1.4 Dialog { standardButtons: StandardButton.Ok - title: "Login" + title: qsTr("Login") Column { anchors.fill: parent Text { - text: "Log in with your library credentials" + text: qsTr("Log in with your library credentials") } TextField { id: username - placeholderText: "patron id" + placeholderText: qsTr("patron id") } TextField { id: password - placeholderText: "password" + placeholderText: qsTr("password") echoMode: TextInput.PasswordEchoOnEdit } } diff --git a/gui/qml/main.qml b/gui/qml/main.qml index 4aab7f1..2ac9398 100644 --- a/gui/qml/main.qml +++ b/gui/qml/main.qml @@ -52,16 +52,20 @@ ApplicationWindow { function toHuman(st) { switch(st) { case "off": - // TODO improve string interpolation, give context to translators etc - return qsTr(ctx.appName + " off"); + //: %1 -> application name + return qsTr("%1 off").arg(ctx.appName); case "on": - return qsTr(ctx.appName + " on"); + //: %1 -> application name + return qsTr("%1 on").arg(ctx.appName); case "connecting": - return qsTr("Connecting to " + ctx.appName); + //: %1 -> application name + return qsTr("Connecting to %1").arg(ctx.appName); case "stopping": - return qsTr("Stopping " + ctx.appName); + //: %1 -> application name + return qsTr("Stopping %1").arg(ctx.appName); case "failed": - return qsTr(ctx.appName + " blocking internet"); // TODO failed is not handed yet + //: %1 -> application name + return qsTr("%1 blocking internet").arg(ctx.appName); // TODO failed is not handed yet } } diff --git a/tools/transifex/Makefile b/tools/transifex/Makefile deleted file mode 100644 index bf5bf2b..0000000 --- a/tools/transifex/Makefile +++ /dev/null @@ -1,8 +0,0 @@ - -all: build generate_json - -build: - go build - -generate_json: - ./transifex g2t ../../locales/en-US/out.gotext.json messages.json diff --git a/tools/transifex/main.go b/tools/transifex/main.go deleted file mode 100644 index 37bae97..0000000 --- a/tools/transifex/main.go +++ /dev/null @@ -1,124 +0,0 @@ -package main - -import ( - "encoding/json" - "fmt" - "os" - "path" - - "golang.org/x/text/message/pipeline" -) - -const ( - outGotext = "out.gotext.json" - messagesGotext = "messages.gotext.json" -) - -type transifex map[string]string - -func main() { - if len(os.Args) < 2 { - panic("g2t or t2g should be passed as argument") - } - - switch os.Args[1] { - case "g2t": - g2t(func(m pipeline.Message) string { return m.Message.Msg }) - case "lang2t": - g2t(func(m pipeline.Message) string { return m.Translation.Msg }) - case "t2g": - t2g() - default: - panic("g2t or t2g should be passed as argument") - } -} - -func g2t(getMessage func(pipeline.Message) string) { - if len(os.Args) < 4 { - panic(fmt.Sprintf("usage: %s g2t inFile outFile", os.Args[0])) - } - - inF, err := os.Open(os.Args[2]) - if err != nil { - panic(fmt.Sprintf("Can't open input file %s: %v", os.Args[2], err)) - } - outF, err := os.Create(os.Args[3]) - if err != nil { - panic(fmt.Sprintf("Can't open output file %s: %v", os.Args[3], err)) - } - - toTransifex(inF, outF, getMessage) -} - -func t2g() { - if len(os.Args) < 3 { - panic(fmt.Sprintf("usage: %s t2g localeFolder", os.Args[0])) - } - - origF, err := os.Open(path.Join(os.Args[2], outGotext)) - if err != nil { - panic(fmt.Sprintf("Can't open file %s/%s: %v", os.Args[3], outGotext, err)) - } - outF, err := os.Create(path.Join(os.Args[2], messagesGotext)) - if err != nil { - panic(fmt.Sprintf("Can't open output file %s/%v: %v", os.Args[3], messagesGotext, err)) - } - toGotext(origF, os.Stdin, outF) -} - -func toTransifex(inF, outF *os.File, getMessage func(pipeline.Message) string) { - messages := pipeline.Messages{} - dec := json.NewDecoder(inF) - err := dec.Decode(&messages) - if err != nil { - panic(fmt.Sprintf("An error ocurred decoding json: %v", err)) - } - - transfx := make(transifex) - for _, m := range messages.Messages { - transfx[m.ID[0]] = getMessage(m) - } - enc := json.NewEncoder(outF) - enc.SetIndent("", " ") - err = enc.Encode(transfx) - if err != nil { - panic(fmt.Sprintf("An error ocurred encoding json: %v", err)) - } -} - -func toGotext(origF, inF, outF *os.File) { - transfx := make(transifex) - dec := json.NewDecoder(inF) - err := dec.Decode(&transfx) - if err != nil { - panic(fmt.Sprintf("An error ocurred decoding json: %v", err)) - } - - messages := pipeline.Messages{} - dec = json.NewDecoder(origF) - err = dec.Decode(&messages) - if err != nil { - panic(fmt.Sprintf("An error ocurred decoding orig json: %v", err)) - } - - for k, v := range transfx { - found := false - for i, m := range messages.Messages { - if m.ID[0] == k { - messages.Messages[i].Translation.Msg = v - found = true - break - } - } - if !found { - fmt.Printf("The original document doesn't have id: %s\n", k) - } - } - - enc := json.NewEncoder(outF) - enc.SetIndent("", " ") - err = enc.Encode(messages) - if err != nil { - panic(fmt.Sprintf("An error ocurred encoding json: %v", err)) - } -} diff --git a/tools/transifex/messages.json b/tools/transifex/messages.json deleted file mode 100644 index a8e0111..0000000 --- a/tools/transifex/messages.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "About": "About", - "About...": "About...", - "Cancel": "Cancel", - "Checking status...": "Checking status...", - "Connecting to {ApplicationName}": "Connecting to {ApplicationName}", - "Donate": "Donate", - "Donate...": "Donate...", - "Error starting VPN": "Error starting VPN", - "Help...": "Help...", - "Initialization error": "Initialization error", - "Missing authentication agent": "Missing authentication agent", - "Quit": "Quit", - "Reconnect": "Reconnect", - "Route traffic through:": "Route traffic through:", - "Stopping {ApplicationName}": "Stopping {ApplicationName}", - "Turn off": "Turn off", - "Turn on": "Turn on", - "Use {ApplicationName} {City} gateway": "Use {ApplicationName} {City} gateway", - "aboutText": "{ApplicationName} is an easy, fast, and secure VPN service from {Provider}. {ApplicationName} does not require a user account, keep logs, or track you in any way.\n\t \nThis service is paid for entirely by donations from users like you. Please donate at {DonateURL}.\n\t\t\nBy using this application, you agree to the Terms of Service available at {TosURL}. This service is provided as-is, without any warranty, and is intended for people who work to make the world a better place.\n\n\n{ApplicationName_1} version: {Version}", - "donationText": "The {ApplicationName} service is expensive to run. Because we don't want to store personal information about you, there are no accounts or billing for this service. But if you want the service to continue, donate at least $5 each month.\n\t\nDo you want to donate now?", - "errorMsg": "An error has ocurred initializing the VPN: {Err}", - "errorStartingVPN": "Can't connect to {ApplicationName}: {Err}", - "missingAuthAgent": "Could not find a polkit authentication agent. Please run one and try again.", - "{ApplicationName} blocking internet": "{ApplicationName} blocking internet", - "{ApplicationName} off": "{ApplicationName} off", - "{ApplicationName} on": "{ApplicationName} on" -} -- cgit v1.2.3