mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-01 02:03:47 +01:00
Fuzzy match lang when user locale doesn't exist.
So for example, fr_CA would select fr_FR rather than en_US. Wrong dialect can sometimes be pretty far off, but it's still likely a better default.
This commit is contained in:
1 parent
3fd67f9199
commit
5fdc72f893
1 file changed
+21
-4
+21
-4
@@ -233,11 +233,28 @@ struct ReportedConfigSetting : public ConfigSetting {
|
||||
};
|
||||
|
||||
const char *DefaultLangRegion() {
|
||||
// Unfortunate default. There's no need to use bFirstRun, since this is only a default.
|
||||
static std::string defaultLangRegion = "en_US";
|
||||
if (g_Config.bFirstRun) {
|
||||
std::string langRegion = System_GetProperty(SYSPROP_LANGREGION);
|
||||
if (i18nrepo.IniExists(langRegion))
|
||||
defaultLangRegion = langRegion;
|
||||
std::string langRegion = System_GetProperty(SYSPROP_LANGREGION);
|
||||
if (i18nrepo.IniExists(langRegion)) {
|
||||
defaultLangRegion = langRegion;
|
||||
} else if (langRegion.length() >= 3) {
|
||||
// Don't give up. Let's try a fuzzy match - so nl_BE can match nl_NL.
|
||||
IniFile mapping;
|
||||
mapping.LoadFromVFS("langregion.ini");
|
||||
std::vector<std::string> keys;
|
||||
mapping.GetKeys("LangRegionNames", keys);
|
||||
|
||||
for (std::string key : keys) {
|
||||
if (startsWithNoCase(key, langRegion)) {
|
||||
// Exact submatch, or different case. Let's use it.
|
||||
defaultLangRegion = key;
|
||||
break;
|
||||
} else if (startsWithNoCase(key, langRegion.substr(0, 3))) {
|
||||
// Best so far.
|
||||
defaultLangRegion = key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return defaultLangRegion.c_str();
|
||||
|
||||
Reference in new issue
Block a user