Fallback to "en" when invalid locale is requested

Close #22365.
This commit is contained in:
Rémi Verschelde 2018-09-23 13:58:01 +02:00
parent 8b2eeaa724
commit 87535fe291
1 changed files with 7 additions and 4 deletions

View File

@ -938,11 +938,14 @@ void TranslationServer::set_locale(const String &p_locale) {
if (!is_locale_valid(univ_locale)) {
String trimmed_locale = get_trimmed_locale(univ_locale);
print_verbose(vformat("Unsupported locale '%s', falling back to '%s'.", p_locale, trimmed_locale));
ERR_EXPLAIN("Invalid locale: " + trimmed_locale);
ERR_FAIL_COND(!is_locale_valid(trimmed_locale));
locale = trimmed_locale;
if (!is_locale_valid(trimmed_locale)) {
ERR_PRINTS(vformat("Unsupported locale '%s', falling back to 'en'.", trimmed_locale));
locale = "en";
} else {
locale = trimmed_locale;
}
} else {
locale = univ_locale;
}