diff options
| author | Damon | 2016-10-27 07:29:00 -0500 |
|---|---|---|
| committer | Rémi Verschelde | 2016-10-31 00:04:39 +0100 |
| commit | e3be51f87c4692f397196210abdcdf4d26c62a60 (patch) | |
| tree | e22fd128445b111614fe3f03bc73d935faa1c0f8 | |
| parent | 68b6b50d28d2321769e0b9e5b3a72e18948580e0 (diff) | |
| download | godot-e3be51f87c4692f397196210abdcdf4d26c62a60.tar.gz godot-e3be51f87c4692f397196210abdcdf4d26c62a60.tar.zst godot-e3be51f87c4692f397196210abdcdf4d26c62a60.zip | |
Fix locale for macOS-style locales
(cherry picked from commit 1e7f078ce9832a1b53be587d1d4cfbd14b760623)
| -rw-r--r-- | core/translation.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/core/translation.cpp b/core/translation.cpp index 0137db3b4..4d81073fe 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -844,8 +844,11 @@ void Translation::_set_messages(const DVector<String>& p_messages){ void Translation::set_locale(const String& p_locale) { - if(!is_valid_locale(p_locale)) { - String trimmed_locale = get_trimmed_locale(p_locale); + // replaces '-' with '_' for macOS Sierra-style locales + String univ_locale = p_locale.replace("-", "_"); + + if(!is_valid_locale(univ_locale)) { + String trimmed_locale = get_trimmed_locale(univ_locale); ERR_EXPLAIN("Invalid Locale: "+trimmed_locale); ERR_FAIL_COND(!is_valid_locale(trimmed_locale)); @@ -853,7 +856,7 @@ void Translation::set_locale(const String& p_locale) { locale=trimmed_locale; } else { - locale=p_locale; + locale=univ_locale; } } @@ -919,8 +922,11 @@ Translation::Translation() { void TranslationServer::set_locale(const String& p_locale) { - if(!is_valid_locale(p_locale)) { - String trimmed_locale = get_trimmed_locale(p_locale); + // replaces '-' with '_' for macOS Sierra-style locales + String univ_locale = p_locale.replace("-", "_"); + + if(!is_valid_locale(univ_locale)) { + String trimmed_locale = get_trimmed_locale(univ_locale); ERR_EXPLAIN("Invalid Locale: "+trimmed_locale); ERR_FAIL_COND(!is_valid_locale(trimmed_locale)); @@ -928,7 +934,7 @@ void TranslationServer::set_locale(const String& p_locale) { locale=trimmed_locale; } else { - locale=p_locale; + locale=univ_locale; } } |
