fix: translation doesn't refresh after switching
This commit is contained in:
parent
f82b7c0345
commit
b0221c662d
@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<!DOCTYPE TS>
|
<!DOCTYPE TS>
|
||||||
<TS version="2.1">
|
<TS version="2.1" language="en_US">
|
||||||
<context>
|
<context>
|
||||||
<name>GpgFrontend::GpgDecryptResultAnalyse</name>
|
<name>GpgFrontend::GpgDecryptResultAnalyse</name>
|
||||||
<message>
|
<message>
|
||||||
|
@ -41,6 +41,8 @@
|
|||||||
|
|
||||||
namespace GpgFrontend::UI {
|
namespace GpgFrontend::UI {
|
||||||
|
|
||||||
|
QList<QTranslator*> registered_translators;
|
||||||
|
|
||||||
extern void InitUITranslations();
|
extern void InitUITranslations();
|
||||||
|
|
||||||
void WaitEnvCheckingProcess() {
|
void WaitEnvCheckingProcess() {
|
||||||
@ -213,31 +215,38 @@ void GPGFRONTEND_UI_EXPORT DestroyGpgFrontendUI() {}
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void InitUITranslations() {
|
void InitUITranslations() {
|
||||||
|
for (const auto& translator : registered_translators) {
|
||||||
|
QCoreApplication::removeTranslator(translator);
|
||||||
|
}
|
||||||
|
registered_translators.clear();
|
||||||
|
|
||||||
auto* translator = new QTranslator(QCoreApplication::instance());
|
auto* translator = new QTranslator(QCoreApplication::instance());
|
||||||
|
if (translator->load(QLocale(), QLatin1String("qt"), QLatin1String("_"),
|
||||||
|
QLatin1String(":/i18n_qt"), QLatin1String(".qm"))) {
|
||||||
|
GF_UI_LOG_DEBUG("load qt translation file done, locale: {}",
|
||||||
|
QLocale().name());
|
||||||
|
|
||||||
|
QCoreApplication::installTranslator(translator);
|
||||||
|
registered_translators.append(translator);
|
||||||
|
}
|
||||||
|
|
||||||
|
translator = new QTranslator(QCoreApplication::instance());
|
||||||
|
if (translator->load(QLocale(), QLatin1String("qtbase"), QLatin1String("_"),
|
||||||
|
QLatin1String(":/i18n_qt"), QLatin1String(".qm"))) {
|
||||||
|
GF_UI_LOG_DEBUG("load qtbase translation file done, locale: {}",
|
||||||
|
QLocale().name());
|
||||||
|
QCoreApplication::installTranslator(translator);
|
||||||
|
registered_translators.append(translator);
|
||||||
|
}
|
||||||
|
|
||||||
|
translator = new QTranslator(QCoreApplication::instance());
|
||||||
if (translator->load(QLocale(), QLatin1String(PROJECT_NAME),
|
if (translator->load(QLocale(), QLatin1String(PROJECT_NAME),
|
||||||
QLatin1String("."), QLatin1String(":/i18n"),
|
QLatin1String("."), QLatin1String(":/i18n"),
|
||||||
QLatin1String(".qm"))) {
|
QLatin1String(".qm"))) {
|
||||||
GF_UI_LOG_DEBUG("load target translation file done, locale: {}",
|
GF_UI_LOG_DEBUG("load target translation file done, locale: {}",
|
||||||
QLocale().name());
|
QLocale().name());
|
||||||
QCoreApplication::installTranslator(translator);
|
QCoreApplication::installTranslator(translator);
|
||||||
}
|
registered_translators.append(translator);
|
||||||
|
|
||||||
auto* base_translation = new QTranslator(QCoreApplication::instance());
|
|
||||||
if (base_translation->load(QLocale(), QLatin1String("qt"), QLatin1String("_"),
|
|
||||||
QLatin1String(":/i18n_qt"),
|
|
||||||
QLatin1String(".qm"))) {
|
|
||||||
GF_UI_LOG_DEBUG("load qt translation file done, locale: {}",
|
|
||||||
QLocale().name());
|
|
||||||
QCoreApplication::installTranslator(base_translation);
|
|
||||||
}
|
|
||||||
|
|
||||||
base_translation = new QTranslator(QCoreApplication::instance());
|
|
||||||
if (base_translation->load(QLocale(), QLatin1String("qtbase"),
|
|
||||||
QLatin1String("_"), QLatin1String(":/i18n_qt"),
|
|
||||||
QLatin1String(".qm"))) {
|
|
||||||
GF_UI_LOG_DEBUG("load qtbase translation file done, locale: {}",
|
|
||||||
QLocale().name());
|
|
||||||
QCoreApplication::installTranslator(base_translation);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user