[Companion] Translation system improvements. (#4676)

* [Companion] I18N:
    * Introduce new Translations class to centralize all related functionality;
    * Add ability to search multiple locations for .qm translation binaries (local folders, resources, system paths);
    * Add ability to reload translations dynamically w/out application restart;
    * Improve support for loading Qt translations (if available);

* [build][i18n] Look for and include pre-built Qt translations with other translation resources; Generate translations.qrc dynamically with rest of build files;  Add EN "translation" file (simpler UI string edits and possible abstractions); Rename ZH translation file to be country-specific.

* [build] Centralize finding all the Qt bits into root CMakeLists; Make sure QT_QMAKE_EXECUTABLE is defined; Disable dysfunctional simulator installer script generation.

* Cosmetics (unused includes).

* [Companion] Make language options menu dynamic based on available translations, and always show native language name; Allow changing language of some elements w/out restarting (esp. menus/toolbar buttons); Simplify menus/actions/handlers for themes and icon sizes.

* [build] Better way to generate translations.qrc using input file again (previous method was generating new qrc for each reconfig);  Make sure common library is linked to other modules which may need it; Remove unused script.
This commit is contained in:
Max Paperno
2017-03-25 13:06:36 +01:00
committed by Bertrand Songis
parent d5560d68f4
commit dcdbff74b0
15 changed files with 12925 additions and 317 deletions
+2 -16
View File
@@ -19,13 +19,9 @@
*/
#include <QApplication>
#include <QDir>
#include <QLibraryInfo>
#include <QLocale>
#include <QMessageBox>
#include <QString>
#include <QTextStream>
#include <QTranslator>
#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
#include <SDL.h>
#undef main
@@ -41,6 +37,7 @@
#include "simulatorstartupdialog.h"
#include "storage.h"
#include "qxtcommandoptions.h"
#include "translations.h"
#include "version.h"
using namespace Simulator;
@@ -83,7 +80,6 @@ int main(int argc, char *argv[])
#endif
Q_INIT_RESOURCE(companion);
Q_INIT_RESOURCE(translations);
if (AppDebugMessageHandler::instance())
AppDebugMessageHandler::instance()->installAppMessageHandler();
@@ -94,17 +90,7 @@ int main(int argc, char *argv[])
QString resultMsg;
QTranslator companionTranslator;
companionTranslator.load(":/companion_" + g.locale());
QTranslator qtTranslator;
#if (QT_VERSION >= QT_VERSION_CHECK(5, 3, 0))
QString qtfile = "qtbase_";
#else
QString qtfile = "qt_";
#endif
qtTranslator.load(qtfile + g.locale().left(2), QLibraryInfo::location(QLibraryInfo::TranslationsPath));
app.installTranslator(&companionTranslator);
app.installTranslator(&qtTranslator);
Translations::installTranslators();
#if defined(JOYSTICKS) || defined(SIMU_AUDIO)
uint32_t sdlFlags = 0;