[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.
This commit is contained in:
David Korth 2025-05-30 19:25:08 -04:00
parent 4e0f741910
commit 11cfd9cd62

View File

@ -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__ */
}
/**