mirror of
https://github.com/azahar-emu/azahar.git
synced 2026-06-05 18:23:39 -04:00
Patch system language selection on Windows (#242)
This commit is contained in:
parent
40d512cafd
commit
2d5404d830
1 changed files with 23 additions and 2 deletions
|
|
@ -3959,14 +3959,35 @@ void GMainWindow::UpdateUITheme() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::LoadTranslation() {
|
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 the selected language is English, no need to install any translation
|
||||||
if (UISettings::values.language == QStringLiteral("en")) {
|
if (UISettings::values.language == QStringLiteral("en")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool loaded;
|
|
||||||
|
|
||||||
if (UISettings::values.language.isEmpty()) {
|
if (UISettings::values.language.isEmpty() && !loaded) {
|
||||||
// Use the system's default locale
|
// Use the system's default locale
|
||||||
loaded = translator.load(QLocale::system(), {}, {}, QStringLiteral(":/languages/"));
|
loaded = translator.load(QLocale::system(), {}, {}, QStringLiteral(":/languages/"));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue