Adding ability to switch language files at runtime to resolve #2743

* Removing .qm files from Windows build as they are inbuilt as of a7adfe251
* Moving translation change code to the OpenRGBSettingsPage
* Adding a changeEvent() to applicable Widgets to facilitate language updates
* Workaround added to TabLabel to accomodate translation context origin
* Added zh_TW locale to OpenRGB.pro
* Updated all translations to include the latest untranslated strings
This commit is contained in:
Chris
2022-11-27 00:10:59 +11:00
committed by Adam Honse
parent 530d667328
commit 2e02f1d782
86 changed files with 6249 additions and 5299 deletions

View File

@@ -18,7 +18,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <thread>
#include <QTranslator>
#ifdef _MACOSX_X86_X64
#include "macUSPCIOAccess.h"
@@ -346,36 +345,6 @@ int main(int argc, char* argv[])
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication a(argc, argv);
/*---------------------------------------------------------*\
| App translation |
| To add a new language: |
| Create a file under qt/i18n/OpenRGB_<locale>.ts |
| Add it to TRANSLATIONS in OpenRGB.pro |
| Edit this file (manually or with |
| linguist qt/i18n/OpenRGB_en.ts qt/i18n/OpenRGB_XX.ts |
\*---------------------------------------------------------*/
QTranslator translator;
QLocale locale = QLocale(QLocale::system());
QLocale::setDefault(locale);
// For local tests without changing the PC locale, override this value.
//locale = QLocale(QLocale::French, QLocale::France);
a.removeTranslator(&translator);
QString path = ":/i18n/";
if(translator.load(path + QString("OpenRGB_%1.qm").arg(locale.name())))
{
a.installTranslator(&translator);
printf("Current Language changed to %s\n", locale.name().toStdString().c_str());
}
else
{
printf("Failed to load translation file for default locale '%s'\n", locale.name().toStdString().c_str());
}
/*---------------------------------------------------------*\
| Main UI widget |
\*---------------------------------------------------------*/