[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:
committed by
Bertrand Songis
parent
d5560d68f4
commit
dcdbff74b0
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) OpenTX
|
||||
*
|
||||
* Based on code named
|
||||
* th9x - http://code.google.com/p/th9x
|
||||
* er9x - http://code.google.com/p/er9x
|
||||
* gruvin9x - http://code.google.com/p/gruvin9x
|
||||
*
|
||||
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#ifndef TRANSLATIONS_H
|
||||
#define TRANSLATIONS_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
// Where to find translation files?
|
||||
// First any path in environment variable OPENTX_APP_TRANSLATIONS_PATH is used if it exists.
|
||||
|
||||
// Default location for .qm files when NOT compiled into application (this is searched after OPENTX_APP_TRANSLATIONS_PATH).
|
||||
#ifndef APP_TRANSLATIONS_FILE_PATH
|
||||
#define APP_TRANSLATIONS_FILE_PATH QCoreApplication::applicationDirPath() % "/translations"
|
||||
#endif
|
||||
\
|
||||
// Default location for .qm files when compiled into application as a resource (this is searched after APP_TRANSLATIONS_FILE_PATH) .
|
||||
#ifndef APP_TRANSLATIONS_RESOURCE_PATH
|
||||
#define APP_TRANSLATIONS_RESOURCE_PATH ":/translations"
|
||||
#endif
|
||||
|
||||
class QLocale;
|
||||
class QTranslator;
|
||||
|
||||
class Translations
|
||||
{
|
||||
public:
|
||||
static QStringList const getTranslationPaths();
|
||||
static QStringList const getAvailableTranslations();
|
||||
static QStringList const getAvailableLanguages();
|
||||
|
||||
static void installTranslators();
|
||||
|
||||
protected:
|
||||
static bool tryLoadTranslator(QTranslator * t, const QLocale & locale, const QString & baseFile, const QStringList & paths);
|
||||
};
|
||||
|
||||
#endif // TRANSLATIONS_H
|
||||
Reference in New Issue
Block a user