From 11cfd9cd6243d72b159d21f568022350c859cbaa Mon Sep 17 00:00:00 2001 From: David Korth Date: Fri, 30 May 2025 19:25:08 -0400 Subject: [PATCH] [qrvthtool] TranslationManager: Set LANG and LC_ALL. This helps a bit with KDE's Open dialog, but the "Cancel" button isn't getting translated for some reason. Similarly, SelectDeviceDialog's "OK" button isn't getting translated, and "Cancel" uses whatever the LC_ALL value was on startup. --- src/qrvthtool/TranslationManager.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/qrvthtool/TranslationManager.cpp b/src/qrvthtool/TranslationManager.cpp index 95fe841..57fe903 100644 --- a/src/qrvthtool/TranslationManager.cpp +++ b/src/qrvthtool/TranslationManager.cpp @@ -196,6 +196,17 @@ void TranslationManager::setTranslation(const QString &locale) //: Locale name, e.g. "en_US". QString tsLocale = tr("C", "ts-locale"); Q_UNUSED(tsLocale) + +#ifdef __linux__ + // Setting LANG and LC_ALL may help with Qt's base translations... + tsLocale += QLatin1String(".UTF-8"); + QByteArray tsLocale_utf8 = tsLocale.toUtf8(); + setenv("LANG", tsLocale_utf8.constData(), 1); + setenv("LC_ALL", tsLocale_utf8.constData(), 1); + + // Reinstall a translator to force Qt to update based on LANG and LC_ALL. + qApp->installTranslator(d->prgTranslator); +#endif /* __linux__ */ } /**