From d27cd4bc2d2f995c3057012f401ef6f7d3deb4e5 Mon Sep 17 00:00:00 2001 From: Alex Spataru Date: Fri, 1 Jan 2021 17:25:52 -0500 Subject: [PATCH] Add translator engine & spanish translations --- Serial-Studio.pro | 6 + assets/assets.qrc | 3 + assets/messages/Welcome_ES.txt | 28 ++ assets/qml/Windows/About.qml | 15 +- assets/qml/Windows/Toolbar.qml | 2 +- assets/translations/en.qm | Bin 0 -> 6443 bytes assets/translations/en.ts | 478 ++++++++++++++++++++++++++++++++ assets/translations/es.qm | Bin 0 -> 11607 bytes assets/translations/es.ts | 486 +++++++++++++++++++++++++++++++++ src/Translator.cpp | 131 +++++++++ src/Translator.h | 64 +++++ src/main.cpp | 6 + 12 files changed, 1215 insertions(+), 4 deletions(-) create mode 100644 assets/messages/Welcome_ES.txt create mode 100644 assets/translations/en.qm create mode 100644 assets/translations/en.ts create mode 100644 assets/translations/es.qm create mode 100644 assets/translations/es.ts create mode 100644 src/Translator.cpp create mode 100644 src/Translator.h diff --git a/Serial-Studio.pro b/Serial-Studio.pro index 5473bdfe..43c3ab20 100644 --- a/Serial-Studio.pro +++ b/Serial-Studio.pro @@ -126,6 +126,7 @@ HEADERS += \ src/ModuleManager.h \ src/QmlBridge.h \ src/SerialManager.h \ + src/Translator.h \ src/Widgets.h SOURCES += \ @@ -138,6 +139,7 @@ SOURCES += \ src/ModuleManager.cpp \ src/QmlBridge.cpp \ src/SerialManager.cpp \ + src/Translator.cpp \ src/Widgets.cpp \ src/main.cpp @@ -145,3 +147,7 @@ DISTFILES += \ assets/qml/Widgets/*.qml \ assets/qml/Windows/*.qml \ assets/qml/*.qml + +TRANSLATIONS += \ + assets/translations/en.ts \ + assets/translations/es.ts diff --git a/assets/assets.qrc b/assets/assets.qrc index fa6a63f3..ddd28df2 100644 --- a/assets/assets.qrc +++ b/assets/assets.qrc @@ -61,5 +61,8 @@ qml/Windows/Widgets.qml qml/main.qml qml/Widgets/ArtificialHorizonDelegate.qml + translations/en.qm + translations/es.qm + messages/Welcome_ES.txt diff --git a/assets/messages/Welcome_ES.txt b/assets/messages/Welcome_ES.txt new file mode 100644 index 00000000..e401872a --- /dev/null +++ b/assets/messages/Welcome_ES.txt @@ -0,0 +1,28 @@ +________ _____ ______ ____________ _____________ +__ ___/______________(_)_____ ___ / __ ___/_ /____ _______ /__(_)_____ +_____ \_ _ \_ ___/_ /_ __ `/_ / _____ \_ __/ / / / __ /__ /_ __ \ +____/ // __/ / _ / / /_/ /_ / ____/ // /_ / /_/ // /_/ / _ / / /_/ / +/____/ \___//_/ /_/ \__,_/ /_/ /____/ \__/ \__,_/ \__,_/ /_/ \____/ + + +¡Bienvenido a Serial Studio! Para comenzar, seleccione un puerto COM y velocidad +en baudios en el panel de dispositivos a la derecha. Si la conexión en serie es +exitosa y los datos entrantes se interpretan correctamente, este panel se +cerrará automáticamente y el el tablero de instrumentos se mostrará +automáticamente. De lo contrario, puede usar la consola para encontrar el origen +de su problema. + +Utilice los botones de la barra de herramientas para mostrar las funciones que +desea utilizar. Si encuentra un problema con Serial Studio, infórmelo en: + + https://github.com/Serial-Studio/Serial-Studio/issues + +También puede utilizar los enlaces de la ventana "Acerca de". Para obtener +documentación sobre uso de Serial Studio e integración con sus proyectos +actuales, por favor lea la wiki: + + https://github.com/Serial-Studio/Serial-Studio/wiki + +¡Que te diviertas! +Alex Spataru (https://github.com/alex-spataru) + diff --git a/assets/qml/Windows/About.qml b/assets/qml/Windows/About.qml index 15a8ed3f..08f0eef7 100644 --- a/assets/qml/Windows/About.qml +++ b/assets/qml/Windows/About.qml @@ -25,7 +25,16 @@ import QtQuick.Layouts 1.12 import QtQuick.Controls 2.12 ApplicationWindow { - id: window + id: root + + // + // Custom properties + // + readonly property int year: new Date().getFullYear() + + // + // Window options + // flags: Qt.Dialog minimumWidth: 320 maximumWidth: 320 @@ -87,7 +96,7 @@ ApplicationWindow { opacity: 0.8 Layout.fillWidth: true wrapMode: Label.WrapAtWordBoundaryOrAnywhere - text: qsTr("Copyright © 2020 %1, released under the MIT License.").arg(CppAppOrganization) + text: qsTr("Copyright © 2020-%1 %2, released under the MIT License.").arg(root.year).arg(CppAppOrganization) } Label { @@ -137,7 +146,7 @@ ApplicationWindow { Button { Layout.fillWidth: true text: qsTr("Close") - onClicked: window.close() + onClicked: root.close() } Item { diff --git a/assets/qml/Windows/Toolbar.qml b/assets/qml/Windows/Toolbar.qml index 6c00d702..e8dcb0da 100644 --- a/assets/qml/Windows/Toolbar.qml +++ b/assets/qml/Windows/Toolbar.qml @@ -121,7 +121,7 @@ Control { onClicked: root.dataClicked() enabled: CppQmlBridge.groupCount > 0 icon.source: "qrc:/icons/equalizer.svg" - text: qsTr("Data Display") + _btSpacer + text: qsTr("Dashboard") + _btSpacer opacity: enabled ? 1 : 0.5 Behavior on opacity {NumberAnimation{}} diff --git a/assets/translations/en.qm b/assets/translations/en.qm new file mode 100644 index 0000000000000000000000000000000000000000..fe5c982457e01bf757738c6e1f04d66a37e89cc3 GIT binary patch literal 6443 zcmcIo3yf6N89u|z?Ci|WzS&f^lpa==E{ZD;CFNOXXCKV6JG0Ep?n+9NGMT>83K-ru+DwYjrjyz{^de|eG+GJ~mYgt+e{#5X`l@L56z zItZzKjF7MXm5{n4#B=BXzTZQry=)iWy7Q~Qnsoo|1nAa~p1nha_+KWsp8$TwOJw6Wen3d&adK$q zz4$$i^&r;W8NH*^_Gsakb7EV2AMjt~(UpKuFadccgw0c5HV?mh$x}ccjY$+^6nH z;tuGO!g?O-Vs~PHJ?uZ>-drAref!;e9(@)1MBRJe*hfgsH{H)Y9ff?${r3J@gm`zm zKhmL(=di~Y`3dmHJqOF@3U{(|S^fAGET-`;r}e}?xvybDfozxH`oUMJ)I z1#fcYt%Q^x_hxqDyZ5v=bM`Ro?DS?Y{0Zw;?=xL4_+_d0`~mD+?FZgVb)fhEy=>kE zH{{(|_O*($p!1gvFPC8N{bhG=ISBjSD0}2A_RAG0+usPiXME(FbKx22-RZk+6ZXgV zIbZ)W*xk_Rd-O>Y?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cxIsp(X2F1Rfb{*-)*&IL@B&FB^*TUvzKw-XCmYO9=0AHCeA_S;pxs9(!|@rLcF3Q z6=z5TV zzVYRwSak6Y)=7M}K>JBEnxz-XxK(+urZRzccEt>B*csrnN-?7m6+r5+t5_>D`*?1X*^qOOH=dWCMvpzG|m|^QkG>=!JJ9!^X(`^7_{Yv*3A$h zx+Z&JO;@y769Nqjy} zTKxDLI-z+_Rb`;R@|J0O=!i9n+KVK0>(CVL|e^mqOJC=j}2``PdIHa z=5$I>QB(xJ7j!I7NKLlQq$^suL>tPAj!|U8DGg~t%m-H=25QzydU{MkhcvZKcA}{0 zmGmv8viD=0%g-WQ;YugI)qws_zwSi9d6#HqAeK&-igm}-{1D + + + + About + + About + + + + Version %1 + + + + The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + + + Contact author + + + + Report bug + + + + Check for updates + + + + Documentation + + + + Close + + + + Copyright © 2020-%1 %2, released under the MIT License. + + + + + AccelerometerDelegate + + G Units + + + + %1 G MAX + + + + %1 G MIN + + + + %1 G ACT + + + + Reset + + + + + Console + + No data received so far... + + + + Autoscroll + + + + Send data to device + + + + + DataGrid + + View + + + + Horizontal Range + + + + Data Groups + + + + Data Plots + + + + Data + + + + + DeviceManager + + Communication Mode + + + + Auto (JSON from serial device) + + + + Manual (use JSON map file) + + + + Change map file (%1) + + + + Select map file + + + + COM Port + + + + Baud Rate + + + + Data Bits + + + + Parity + + + + Stop Bits + + + + Flow Control + + + + + Downloader + + Updater + + + + Downloading updates + + + + Time remaining: 0 minutes + + + + Open + + + + Stop + + + + Time remaining + + + + unknown + + + + Error + + + + Cannot find downloaded update! + + + + Close + + + + Download complete! + + + + The installer will open separately + + + + Click "OK" to begin installing the update + + + + In order to install the update, you may need to quit the application. + + + + In order to install the update, you may need to quit the application. This is a mandatory update, exiting now will close the application + + + + Click the "Open" button to apply the update + + + + Are you sure you want to cancel the download? + + + + Are you sure you want to cancel the download? This is a mandatory update, exiting now will close the application + + + + %1 bytes + + + + %1 KB + + + + %1 MB + + + + of + + + + Downloading Updates + + + + Time Remaining + + + + Unknown + + + + about %1 hours + + + + about one hour + + + + %1 minutes + + + + 1 minute + + + + %1 seconds + + + + 1 second + + + + + Export + + CSV file not open + + + + Cannot find CSV export file! + + + + CSV File Error + + + + Cannot open CSV file for writing! + + + + + Group + + Invalid + + + + + GyroDelegate + + %1° YAW + + + + %1° ROLL + + + + %1° PITCH + + + + + JsonParser + + Select JSON map file + + + + JSON files (*.json) + + + + JSON parse error + + + + JSON map file loaded successfully! + + + + File "%1" loaded into memory + + + + Cannot read JSON file + + + + Please check file permissions & location + + + + + QObject + + Failed to load welcome text :( + + + + :/messages/Welcome_EN.txt + + + + + SerialManager + + No Parity + + + + One + + + + No Flow Control + + + + No Device + + + + Received: %1 %2 + + + + Even Parity + + + + Odd Parity + + + + Space Parity + + + + Mark Parity + + + + One and Half + + + + Two + + + + Hardware Control + + + + Software Control + + + + Select Port + + + + + Toolbar + + Devices + + + + Console + + + + Widgets + + + + About + + + + CSV Export + + + + Open past CSV + + + + Open current CSV + + + + Dashboard + + + + + Updater + + Would you like to download the update now? + + + + Would you like to download the update now? This is a mandatory update, exiting now will close the application + + + + Version %1 of %2 has been released! + + + + No updates are available for the moment + + + + Congratulations! You are running the latest version of %1 + + + + diff --git a/assets/translations/es.qm b/assets/translations/es.qm new file mode 100644 index 0000000000000000000000000000000000000000..c899cc94df2334dacdf943783386411539a56e1b GIT binary patch literal 11607 zcmd5?4R9RQeSh-lbkga=vMh-0y6W@UB4=0lLjh0h5Yp3~ET53>#NA1@r*2_&w~|)A z+dX#oB#UV~oo3Q{I!%Uz0wE!E9GV2$G)H!2x$rqWuViKFew?AArR6uoiL?^ zX_Nl`@9pmG-R;THAssNMz1w~7|NZ^;hOd-%JoUr-?s|I9?#FJu_|<>@0%L58YE3W} zx|OlW0%JS=m9d3M#$r1e`^E1tw)Y9v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3G(LB&4J z%PPplx=h1P2P}v@0Vz{#k?%gpdPdH_{Zgb<>zA7hWUlnaeU;tb`a3h6#4^rT6bqwo zn3?+;m?-TUBy|?YIWvL?IxUma4wL;rs7$KdEifsmxoHBk6(KTQh3ku+yAQ8Ms%&oNWwt;_5k8vJ=;zktGI IOGn550+kS(hyVZp literal 0 HcmV?d00001 diff --git a/assets/translations/es.ts b/assets/translations/es.ts new file mode 100644 index 00000000..3c95b981 --- /dev/null +++ b/assets/translations/es.ts @@ -0,0 +1,486 @@ + + + + + About + + About + Acerca de + + + Version %1 + Versión %1 + + + Copyright © 2020 %1, released under the MIT License. + Copyright © 2020 %1, distribuido bajo la licencia MIT. + + + The program is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + El programa se proporciona TAL CUAL, SIN GARANTÍA DE NINGÚN TIPO, INCLUIDA LA GARANTÍA DE DISEÑO, COMERCIABILIDAD Y APTITUD PARA UN PROPÓSITO EN PARTICULAR. + + + Contact author + Contactar al autor + + + Report bug + Reportar un error + + + Check for updates + Buscar actualizaciones + + + Documentation + Documentación + + + Close + Cerrar + + + Copyright © 2020-%1 %2, released under the MIT License. + Copyright © 2020-%1 %2, distribuido bajo la licencia MIT. + + + + AccelerometerDelegate + + G Units + Unidades G + + + %1 G MAX + %1 G MAX + + + %1 G MIN + %1 G MIN + + + %1 G ACT + %1 G ACT + + + Reset + Reajustar + + + + Console + + No data received so far... + No se han recibido datos hasta ahora ... + + + Autoscroll + Desplazamiento automático + + + Send data to device + Enviar datos al dispositivo + + + + DataGrid + + View + Vista + + + Horizontal Range + Rango Horizontal + + + Data Groups + Grupos de Datos + + + Data Plots + Gráficos de Datos + + + Data + Datos + + + + DeviceManager + + Communication Mode + Modo de comunicación + + + Auto (JSON from serial device) + Automático (JSON desde puerto serial) + + + Manual (use JSON map file) + Manual (usar archivo de mapa JSON) + + + Change map file (%1) + Cambiar archivo (%1) + + + Select map file + Seleccionar archivo de mapa + + + COM Port + Puerto COM + + + Baud Rate + Baudios + + + Data Bits + Bits de datos + + + Parity + Paridad + + + Stop Bits + Bits de parada + + + Flow Control + Control de flujo + + + + Downloader + + Updater + Actualizador + + + Downloading updates + Descargando actualizaciones + + + Time remaining: 0 minutes + Tiempo restante: 0 minutos + + + Open + Abrir + + + Stop + Cancelar + + + Time remaining + Tiempo restante + + + unknown + desconocido + + + Error + Error + + + Cannot find downloaded update! + No se puede encontrar el archivo descargado! + + + Close + Cerrar + + + Download complete! + Descarga completa! + + + The installer will open separately + El instalador se abrirá por separado + + + Click "OK" to begin installing the update + Haga clic en "Aceptar" para comenzar a instalar la actualización + + + In order to install the update, you may need to quit the application. + Para instalar la actualización, es posible que deba salir de la aplicación. + + + In order to install the update, you may need to quit the application. This is a mandatory update, exiting now will close the application + Para instalar la actualización, es posible que deba salir de la aplicación. Esta es una actualización obligatoria, salir ahora cerrará la aplicación + + + Click the "Open" button to apply the update + Haga clic en el botón "Abrir" para instalar la actualización + + + Are you sure you want to cancel the download? + ¿Estás seguro/a de que deseas cancelar la descarga? + + + Are you sure you want to cancel the download? This is a mandatory update, exiting now will close the application + ¿Estás seguro/a de que deseas cancelar la descarga? Esta es una actualización obligatoria, salir ahora cerrará la aplicación + + + %1 bytes + + + + %1 KB + + + + %1 MB + + + + of + de + + + Downloading Updates + Descargando actualizaciones + + + Time Remaining + Tiempo restante + + + Unknown + Desconocido + + + about %1 hours + alrededor de %1 horas + + + about one hour + alrededor de una hora + + + %1 minutes + %1 minutos + + + 1 minute + 1 minuto + + + %1 seconds + %1 segundos + + + 1 second + 1 segundo + + + + Export + + CSV file not open + Archivo CSV no abierto + + + Cannot find CSV export file! + ¡No se puede encontrar el archivo de exportación CSV! + + + CSV File Error + Error de archivo CSV + + + Cannot open CSV file for writing! + ¡No se puede abrir el archivo CSV en modo de escritura! + + + + Group + + Invalid + Inválido + + + + GyroDelegate + + %1° YAW + + + + %1° ROLL + + + + %1° PITCH + + + + + JsonParser + + Select JSON map file + Seleccionar mapa JSON + + + JSON files (*.json) + Archivos JSON (*.json) + + + JSON parse error + Error de lectura de JSON + + + JSON map file loaded successfully! + ¡El archivo de mapa JSON se cargó correctamente! + + + File "%1" loaded into memory + Archivo "%1" cargado en memoria + + + Cannot read JSON file + Error de lectura del archivo JSON + + + Please check file permissions & location + Verifique los permisos y la ubicación del archivo + + + + QObject + + Failed to load welcome text :( + Error al cargar el texto de bienvenida :( + + + :/messages/Welcome_EN.txt + :/messages/Welcome_ES.txt + + + + SerialManager + + No Parity + Sin Paridad + + + One + Uno + + + No Flow Control + Sin control de flujo + + + No Device + Sin Dispositivo + + + Received: %1 %2 + Recibido: %1 %2 + + + Even Parity + Par + + + Odd Parity + Inpar + + + Space Parity + Espacio + + + Mark Parity + Marca + + + One and Half + Uno y Medio + + + Two + Dos + + + Hardware Control + Controlado por hardware + + + Software Control + Controlado por software + + + Select Port + Seleccionar Puerto + + + + Toolbar + + Devices + Dispositivos + + + Console + Consola + + + Data Display + Visualización de Datos + + + Widgets + Widgets + + + About + Acerca de + + + CSV Export + Exportación CSV + + + Open past CSV + Abrir CSV pasado + + + Open current CSV + Abrir CSV actual + + + Dashboard + Tablero + + + + Updater + + Would you like to download the update now? + ¿Le gustaría descargar la actualización ahora? + + + Would you like to download the update now? This is a mandatory update, exiting now will close the application + ¿Le gustaría descargar la actualización ahora? Esta es una actualización obligatoria, salir ahora cerrará la aplicación + + + Version %1 of %2 has been released! + ¡Se ha lanzado la versión %1 de %2! + + + No updates are available for the moment + No hay actualizaciones disponibles por el momento + + + Congratulations! You are running the latest version of %1 + ¡Felicidades! Estás ejecutando la última versión de %1 + + + diff --git a/src/Translator.cpp b/src/Translator.cpp new file mode 100644 index 00000000..25ee3113 --- /dev/null +++ b/src/Translator.cpp @@ -0,0 +1,131 @@ +/* + * Copyright (c) 2020 Alex Spataru + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include "Translator.h" + +/** + * Constructor function + */ +Translator::Translator() +{ + m_language = 0; +} + +/** + * Returns the current language ID, which corresponds to the indexes of the languages returned + * by the \c availableLanguages() function. + */ +int Translator::language() const +{ + return m_language; +} + +/** + * Returns the appropiate language ID based on the current locale settings of the host's operating + * system. + */ +int Translator::systemLanguage() const +{ + int lang; + switch (QLocale::system().language()) + { + case QLocale::English: + lang = 0; + break; + case QLocale::Spanish: + lang = 1; + break; + default: + lang = 0; + break; + } + + return lang; +} + +/** + * Returns an empty string, this function should be used with QML to automatically update + * all the strings without the need of restarting the application. For example, the following + * QML code: + * + * text: qsTr("Text") + CppTranslator.dummyString + * + * Will force the QML interface to update the value of @a text when the language is changed. + */ +QString Translator::dummyString() const +{ + return ""; +} + +/** + * Returns a list with the available translation languages. + */ +QStringList Translator::availableLanguages() const +{ + return QStringList { "English", "Español" }; +} + +/** + * Changes the language of the application and emits the signals appropiate to reload every + * string that uses the Qt translator system. + * + * @param language language ID based on the indexes of the \a availableLanguages() function + */ +void Translator::setLanguage(const int language) +{ + QString langName; + QLocale locale; + switch (language) + { + case 0: + langName = "en"; + locale = QLocale(QLocale::English); + break; + case 1: + langName = "es"; + locale = QLocale(QLocale::Spanish); + break; + default: + langName = "en"; + locale = QLocale(QLocale::English); + break; + } + + m_language = language; + setLanguage(locale, langName); +} + +/** + * Changes the language of the application and emits the signals neccesary to reload every + * string that uses the Qt translator system. + * + * @param locale user-set locale + * @param language name of the *.qm file to load from the "translations" directory inside the + * application's resources + */ +void Translator::setLanguage(const QLocale &locale, const QString &language) +{ + qApp->removeTranslator(&m_translator); + m_translator.load(locale, ":/translations/" + language + ".qm"); + qApp->installTranslator(&m_translator); + emit languageChanged(); +} diff --git a/src/Translator.h b/src/Translator.h new file mode 100644 index 00000000..7e2ff82a --- /dev/null +++ b/src/Translator.h @@ -0,0 +1,64 @@ +/* + * Copyright (c) 2020 Alex Spataru + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef TRANSLATOR_H +#define TRANSLATOR_H + +#include +#include +#include + +#ifdef QT_QML_LIB +# include +#endif + +class Translator : public QObject +{ + Q_OBJECT + +#ifdef QT_QML_LIB + Q_PROPERTY(int language READ language WRITE setLanguage NOTIFY languageChanged) + Q_PROPERTY(QString dummy READ dummyString NOTIFY languageChanged) + Q_PROPERTY(QStringList availableLanguages READ availableLanguages CONSTANT) +#endif + +signals: + void languageChanged(); + +public: + explicit Translator(); + + int language() const; + int systemLanguage() const; + QString dummyString() const; + QStringList availableLanguages() const; + +public slots: + void setLanguage(const int language); + void setLanguage(const QLocale &locale, const QString &language); + +private: + int m_language; + QTranslator m_translator; +}; + +#endif diff --git a/src/main.cpp b/src/main.cpp index 1080c950..ebe8fab9 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,6 +40,7 @@ #include "GraphProvider.h" #include "SerialManager.h" +#include "Translator.h" #include "ModuleManager.h" /** @@ -93,6 +94,11 @@ int main(int argc, char **argv) qmlRegisterType("Group", 1, 0, "Group"); qmlRegisterType("Dataset", 1, 0, "Dataset"); + // Start translator & set lenguage + Translator translator; + // QLocale locale(QLocale::Spanish, QLocale::Mexico); + // translator.setLanguage(locale, "es"); + // Get console welcome text string QString welcomeText = QObject::tr("Failed to load welcome text :("); QFile file(QObject::tr(":/messages/Welcome_EN.txt"));