mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2026-02-17 08:03:04 -07:00
Patch system language selection on Windows (#242)
This commit is contained in:
parent
40d512cafd
commit
2d5404d830
@ -3959,14 +3959,35 @@ void GMainWindow::UpdateUITheme() {
|
||||
}
|
||||
|
||||
void GMainWindow::LoadTranslation() {
|
||||
bool loaded{false};
|
||||
|
||||
#ifdef _WIN32
|
||||
// Set the language to the first option in "preferred languages" Windows' OS settings
|
||||
if (UISettings::values.language.isEmpty()) {
|
||||
|
||||
const auto languages = QLocale::system().uiLanguages(QLocale::TagSeparator::Underscore);
|
||||
for (const auto& lang : languages) {
|
||||
// If the first language found is English, no need to install any translation
|
||||
if (lang == QStringLiteral("en")) {
|
||||
UISettings::values.language = lang;
|
||||
return;
|
||||
}
|
||||
loaded = translator.load(lang, QStringLiteral(":/languages/"));
|
||||
if (loaded) {
|
||||
UISettings::values.language = lang;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
// If the selected language is English, no need to install any translation
|
||||
if (UISettings::values.language == QStringLiteral("en")) {
|
||||
return;
|
||||
}
|
||||
|
||||
bool loaded;
|
||||
|
||||
if (UISettings::values.language.isEmpty()) {
|
||||
if (UISettings::values.language.isEmpty() && !loaded) {
|
||||
// Use the system's default locale
|
||||
loaded = translator.load(QLocale::system(), {}, {}, QStringLiteral(":/languages/"));
|
||||
} else {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user