fix(TranslationsModel): use proper way to get system locale

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
This commit is contained in:
Octol1ttle 2026-05-03 16:23:45 +05:00
parent 031015b332
commit 6b5615ece9
No known key found for this signature in database
GPG key ID: B77C34313AEE1FFF

View file

@ -433,7 +433,7 @@ std::optional<Language> TranslationsModel::findLanguageAsOptional(const QString&
void TranslationsModel::setUseSystemLocale(bool useSystemLocale)
{
APPLICATION->settings()->set("UseSystemLocale", useSystemLocale);
QLocale::setDefault(QLocale(useSystemLocale ? QString::fromStdString(std::locale().name()) : defaultLangCode));
QLocale::setDefault(useSystemLocale ? QLocale::system() : QLocale(defaultLangCode));
}
bool TranslationsModel::selectLanguage(QString key)
@ -467,8 +467,8 @@ bool TranslationsModel::selectLanguage(QString key)
* In a multithreaded application, the default locale should be set at application startup, before any non-GUI threads are created.
* This function is not reentrant.
*/
QLocale::setDefault(
QLocale(APPLICATION->settings()->get("UseSystemLocale").toBool() ? QString::fromStdString(std::locale().name()) : langCode));
const bool useSystemLocale = APPLICATION->settings()->get("UseSystemLocale").toBool();
QLocale::setDefault(useSystemLocale ? QLocale::system() : QLocale(langCode));
// if it's the default UI language, finish
if (langCode == defaultLangCode) {