diff --git a/src/common/config.cpp b/src/common/config.cpp index 82eba2a4e..e26a998f5 100644 --- a/src/common/config.cpp +++ b/src/common/config.cpp @@ -768,21 +768,7 @@ void load(const std::filesystem::path& path) { m_elf_viewer = toml::find_or>(gui, "elfDirs", {}); m_recent_files = toml::find_or>(gui, "recentFiles", {}); m_table_mode = toml::find_or(gui, "gameTableMode", 0); - emulator_language = toml::find_or(gui, "emulatorLanguage", "en_US"); - - // Check if the loaded language is in the allowed list - const std::vector allowed_languages = { - "ar_SA", "da_DK", "de_DE", "el_GR", "en_US", "es_ES", "fa_IR", - "fi_FI", "fr_FR", "hu_HU", "id_ID", "it_IT", "ja_JP", "ko_KR", - "lt_LT", "nl_NL", "no_NO", "pl_PL", "pt_BR", "ro_RO", "ru_RU", - "sq_AL", "sv_SE", "tr_TR", "uk_UA", "vi_VN", "zh_CN", "zh_TW"}; - - if (std::find(allowed_languages.begin(), allowed_languages.end(), emulator_language) == - allowed_languages.end()) { - emulator_language = "en_US"; // Default to en_US if not in the list - save(path); - } backgroundImageOpacity = toml::find_or(gui, "backgroundImageOpacity", 50); showBackgroundImage = toml::find_or(gui, "showBackgroundImage", true); } @@ -797,6 +783,18 @@ void load(const std::filesystem::path& path) { const toml::value& keys = data.at("Keys"); trophyKey = toml::find_or(keys, "TrophyKey", ""); } + + // Check if the loaded language is in the allowed list + const std::vector allowed_languages = { + "ar_SA", "da_DK", "de_DE", "el_GR", "en_US", "es_ES", "fa_IR", "fi_FI", "fr_FR", "hu_HU", + "id_ID", "it_IT", "ja_JP", "ko_KR", "lt_LT", "nl_NL", "no_NO", "pl_PL", "pt_BR", "ro_RO", + "ru_RU", "sq_AL", "sv_SE", "tr_TR", "uk_UA", "vi_VN", "zh_CN", "zh_TW"}; + + if (std::find(allowed_languages.begin(), allowed_languages.end(), emulator_language) == + allowed_languages.end()) { + emulator_language = "en_US"; // Default to en_US if not in the list + save(path); + } } void save(const std::filesystem::path& path) {