diff --git a/src/gui/modals/SetupDialog.cpp b/src/gui/modals/SetupDialog.cpp index d29608653..5140a63b5 100644 --- a/src/gui/modals/SetupDialog.cpp +++ b/src/gui/modals/SetupDialog.cpp @@ -264,11 +264,22 @@ SetupDialog::SetupDialog(ConfigTabs tab_to_open) : QStringList fileNames = dir.entryList(QStringList("*.qm")); for(int i = 0; i < fileNames.size(); ++i) { - // Get locale extracted by filename. + // Extract ISO-639 language code from filename fileNames[i].truncate(fileNames[i].lastIndexOf('.')); + // Skip invalid language codes + QLocale locale(fileNames[i]); + if (locale.language() == QLocale::C) + { + continue; + } + // Display the native language name or fallback to the English name + QString langName = locale.nativeLanguageName(); + if (langName.isEmpty()) + { + langName = QLocale::languageToString(locale.language()); + } m_languages.append(fileNames[i]); - QString lang = QLocale(m_languages.last()).nativeLanguageName(); - changeLang->addItem(lang); + changeLang->addItem(langName); } // If language unset, fallback to system language when available. @@ -1352,4 +1363,4 @@ void SetupDialog::showRestartWarning() } -} // namespace lmms::gui \ No newline at end of file +} // namespace lmms::gui