diff --git a/src/duckstation-qt/mainwindow.cpp b/src/duckstation-qt/mainwindow.cpp index f8d48ff56..3e09b0c21 100644 --- a/src/duckstation-qt/mainwindow.cpp +++ b/src/duckstation-qt/mainwindow.cpp @@ -970,8 +970,8 @@ void MainWindow::setupAdditionalUi() connect(action, &QAction::triggered, [this, action]() { const QString new_language = action->data().toString(); m_host_interface->SetStringSettingValue("Main", "Language", new_language.toUtf8().constData()); - QMessageBox::information(this, tr("DuckStation"), - tr("Language changed. Please restart the application to apply.")); + m_host_interface->reinstallTranslator(); + recreate(); }); } diff --git a/src/duckstation-qt/qthostinterface.cpp b/src/duckstation-qt/qthostinterface.cpp index 5b1fb4a63..a040c5796 100644 --- a/src/duckstation-qt/qthostinterface.cpp +++ b/src/duckstation-qt/qthostinterface.cpp @@ -158,7 +158,20 @@ void QtHostInterface::installTranslator() } Log_InfoPrintf("Loaded translation file for language '%s'", language.c_str()); - qApp->installTranslator(translator.release()); + qApp->installTranslator(translator.get()); + m_translators.push_back(translator.release()); +} + +void QtHostInterface::reinstallTranslator() +{ + for (QTranslator* translator : m_translators) + { + qApp->removeTranslator(translator); + translator->deleteLater(); + } + m_translators.clear(); + + installTranslator(); } void QtHostInterface::ReportError(const char* message) diff --git a/src/duckstation-qt/qthostinterface.h b/src/duckstation-qt/qthostinterface.h index bfedecbb9..6f9f218de 100644 --- a/src/duckstation-qt/qthostinterface.h +++ b/src/duckstation-qt/qthostinterface.h @@ -91,6 +91,7 @@ public: void setMainWindow(MainWindow* window); HostDisplay* createHostDisplay(); void connectDisplaySignals(QtDisplayWidget* widget); + void reinstallTranslator(); void populateLoadStateMenu(const char* game_code, QMenu* menu); void populateSaveStateMenu(const char* game_code, QMenu* menu); @@ -285,6 +286,7 @@ private: QTimer* m_background_controller_polling_timer = nullptr; std::unique_ptr m_settings_save_timer; + std::vector m_translators; bool m_is_rendering_to_main = false; bool m_is_fullscreen = false;