mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2026-05-14 01:24:39 -04:00
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:
31
main.cpp
31
main.cpp
@@ -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 |
|
||||
\*---------------------------------------------------------*/
|
||||
|
||||
Reference in New Issue
Block a user