aboutsummaryrefslogtreecommitdiff
path: root/core/translation.cpp
diff options
context:
space:
mode:
authorRémi Verschelde2016-10-27 14:37:44 +0200
committerGitHub2016-10-27 14:37:44 +0200
commit8321e48ab0ac0700e1aef8f829140052c1ba4c6d (patch)
treea03d627a76fb4456d938f591a5ee01f7e6e9b2c2 /core/translation.cpp
parent470ead74dbc3d6ea7133ab90c0d09ed637e7a5f5 (diff)
parent1e7f078ce9832a1b53be587d1d4cfbd14b760623 (diff)
downloadgodot-8321e48ab0ac0700e1aef8f829140052c1ba4c6d.tar.gz
godot-8321e48ab0ac0700e1aef8f829140052c1ba4c6d.tar.zst
godot-8321e48ab0ac0700e1aef8f829140052c1ba4c6d.zip
Merge pull request #6943 from damon-myers/fix-mac-locale
Fix locale for macOS-style locales
Diffstat (limited to 'core/translation.cpp')
-rw-r--r--core/translation.cpp18
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;
}
}