Qt: Fix up how the language names get displayed

This commit is contained in:
Vicki Pfau 2024-12-12 04:02:56 -08:00
parent c2741c73db
commit 0ca391cffc
1 changed files with 12 additions and 2 deletions

View File

@ -357,7 +357,7 @@ SettingsView::SettingsView(ConfigController* controller, InputController* inputC
}); });
QLocale englishLocale("en"); QLocale englishLocale("en");
m_ui.languages->addItem(englishLocale.nativeLanguageName(), englishLocale); m_ui.languages->addItem("English", englishLocale);
QDir ts(":/translations/"); QDir ts(":/translations/");
for (auto& name : ts.entryList()) { for (auto& name : ts.entryList()) {
if (!name.endsWith(".qm") || !name.startsWith(binaryName)) { if (!name.endsWith(".qm") || !name.startsWith(binaryName)) {
@ -367,7 +367,17 @@ SettingsView::SettingsView(ConfigController* controller, InputController* inputC
if (locale.language() == QLocale::English) { if (locale.language() == QLocale::English) {
continue; continue;
} }
m_ui.languages->addItem(locale.nativeLanguageName(), locale); QString endonym = locale.nativeLanguageName();
// Manualy handle some cases that Qt can't seem to do properly
if (locale.language() == QLocale::Spanish) {
// Qt insists this is called español de España, regardless of if we set the country
endonym = u8"Español";
} else if (locale.language() == QLocale::Portuguese && locale.country() == QLocale::Brazil) {
// Qt insists that Brazilian Portuguese is just called Português
endonym = u8"Português brasileiro";
}
endonym[0] = endonym[0].toUpper();
m_ui.languages->addItem(endonym, locale);
if (locale.bcp47Name() == QLocale().bcp47Name()) { if (locale.bcp47Name() == QLocale().bcp47Name()) {
m_ui.languages->setCurrentIndex(m_ui.languages->count() - 1); m_ui.languages->setCurrentIndex(m_ui.languages->count() - 1);
} }