From 488c60971e0b9a22af3d99e0daaf86bffda69990 Mon Sep 17 00:00:00 2001 From: scribblemaniac Date: Sun, 28 Apr 2024 10:51:14 -0600 Subject: [PATCH] Warn that translation changes require restart in new language --- app/src/generalpage.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/src/generalpage.cpp b/app/src/generalpage.cpp index 8338355a9..1dcb1dde3 100644 --- a/app/src/generalpage.cpp +++ b/app/src/generalpage.cpp @@ -19,6 +19,7 @@ GNU General Public License for more details. #include #include +#include #include "pencildef.h" #include "preferencemanager.h" @@ -197,9 +198,19 @@ void GeneralPage::languageChanged(int i) QString strLocale = ui->languageCombo->itemData(i).toString(); mManager->set(SETTING::LANGUAGE, strLocale); - QMessageBox::warning(this, - tr("Restart Required"), - tr("The language change will take effect after a restart of Pencil2D")); + QLocale locale = strLocale.isEmpty() ? QLocale::system() : QLocale(strLocale); + std::unique_ptr newlangTr(new QTranslator(this)); + if (newlangTr->load(locale, "pencil", "_", ":/i18n/")) + { + QMessageBox::warning(this, + newlangTr->translate(staticMetaObject.className(), "Restart Required"), + newlangTr->translate(staticMetaObject.className(), "The language change will take effect after a restart of Pencil2D")); + } else { + Q_ASSERT(false); + QMessageBox::warning(this, + tr("Restart Required"), + tr("The language change will take effect after a restart of Pencil2D")); + } } void GeneralPage::backgroundChanged(QAbstractButton* button)