mirror of
https://github.com/Relintai/pandemonium_engine.git
synced 2024-11-21 16:37:20 +01:00
Do not auto add default script and country codes to the locale.
This commit is contained in:
parent
06cc39ad91
commit
b0701da063
@ -254,6 +254,10 @@ void TranslationServer::init_locale_info() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String TranslationServer::standardize_locale(const String &p_locale) const {
|
String TranslationServer::standardize_locale(const String &p_locale) const {
|
||||||
|
return _standardize_locale(p_locale, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
String TranslationServer::_standardize_locale(const String &p_locale, bool p_add_defaults) const {
|
||||||
// Replaces '-' with '_' for macOS style locales.
|
// Replaces '-' with '_' for macOS style locales.
|
||||||
String univ_locale = p_locale.replace("-", "_");
|
String univ_locale = p_locale.replace("-", "_");
|
||||||
|
|
||||||
@ -315,24 +319,26 @@ String TranslationServer::standardize_locale(const String &p_locale) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add script code base on language and country codes for some ambiguous cases.
|
// Add script code base on language and country codes for some ambiguous cases.
|
||||||
if (script.empty()) {
|
if (p_add_defaults) {
|
||||||
for (int i = 0; i < locale_script_info.size(); i++) {
|
if (script.empty()) {
|
||||||
const LocaleScriptInfo &info = locale_script_info[i];
|
for (int i = 0; i < locale_script_info.size(); i++) {
|
||||||
if (info.name == lang) {
|
const LocaleScriptInfo &info = locale_script_info[i];
|
||||||
if (country.empty() || info.supported_countries.has(country)) {
|
if (info.name == lang) {
|
||||||
script = info.script;
|
if (country.empty() || info.supported_countries.has(country)) {
|
||||||
break;
|
script = info.script;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
if (!script.empty() && country.empty()) {
|
||||||
if (!script.empty() && country.empty()) {
|
// Add conntry code based on script for some ambiguous cases.
|
||||||
// Add conntry code based on script for some ambiguous cases.
|
for (int i = 0; i < locale_script_info.size(); i++) {
|
||||||
for (int i = 0; i < locale_script_info.size(); i++) {
|
const LocaleScriptInfo &info = locale_script_info[i];
|
||||||
const LocaleScriptInfo &info = locale_script_info[i];
|
if (info.name == lang && info.script == script) {
|
||||||
if (info.name == lang && info.script == script) {
|
country = info.default_country;
|
||||||
country = info.default_country;
|
break;
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -352,8 +358,8 @@ String TranslationServer::standardize_locale(const String &p_locale) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int TranslationServer::compare_locales(const String &p_locale_a, const String &p_locale_b) const {
|
int TranslationServer::compare_locales(const String &p_locale_a, const String &p_locale_b) const {
|
||||||
String locale_a = standardize_locale(p_locale_a);
|
String locale_a = _standardize_locale(p_locale_a, true);
|
||||||
String locale_b = standardize_locale(p_locale_b);
|
String locale_b = _standardize_locale(p_locale_b, true);
|
||||||
|
|
||||||
if (locale_a == locale_b) {
|
if (locale_a == locale_b) {
|
||||||
// Exact match.
|
// Exact match.
|
||||||
|
@ -123,6 +123,7 @@ public:
|
|||||||
|
|
||||||
int compare_locales(const String &p_locale_a, const String &p_locale_b) const;
|
int compare_locales(const String &p_locale_a, const String &p_locale_b) const;
|
||||||
String standardize_locale(const String &p_locale) const;
|
String standardize_locale(const String &p_locale) const;
|
||||||
|
String _standardize_locale(const String &p_locale, bool p_add_defaults) const;
|
||||||
|
|
||||||
Vector<String> get_all_languages() const;
|
Vector<String> get_all_languages() const;
|
||||||
String get_language_name(const String &p_language) const;
|
String get_language_name(const String &p_language) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user