Godot Engine – Multi-platform 2D and 3D game engine
[Editor] Fix multiple issues with preferred locale list.
Pāvels Nadtočajevs089b797dc8ca
diff --git a/editor/settings/editor_settings.cpp b/editor/settings/editor_settings.cppindex 1e39004fd2c..a416b148590 100644--- a/editor/settings/editor_settings.cpp+++ b/editor/settings/editor_settings.cpp@@ -424,10 +424,16 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {WARN_PRINT("Some locales are not properly supported by selected Text Server and are disabled.");}- String lang_hint;String best = "en";int best_score = 0;for (const String &host_lang : OS::get_singleton()->get_preferred_locales()) {+ if (host_lang.get_slicec('_', 0) == "en") {+ int score = TranslationServer::get_singleton()->compare_locales(host_lang, "en");+ if (score > 0 && score >= best_score) {+ best = "en";+ best_score = score;+ }+ }for (const String &locale : get_editor_locales()) {// Test against language code without regional variants (e.g. ur_PK).String lang_code = locale.get_slicec('_', 0);@@ -435,10 +441,6 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {continue;}- lang_hint += ";";- const String lang_name = TranslationServer::get_singleton()->get_locale_name(locale);- lang_hint += vformat("%s/[%s] %s", locale, locale, lang_name);-int score = TranslationServer::get_singleton()->compare_locales(host_lang, locale);if (score > 0 && score >= best_score) {best = locale;@@ -449,6 +451,13 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {break;}}++ String lang_hint;+ for (const String &locale : get_editor_locales()) {+ lang_hint += ";";+ const String lang_name = TranslationServer::get_singleton()->get_locale_name(locale);+ lang_hint += vformat("%s/[%s] %s", locale, locale, lang_name);+ }lang_hint = vformat(";auto/Auto (%s);en/[en] English", TranslationServer::get_singleton()->get_locale_name(best)) + lang_hint;EDITOR_SETTING_USAGE(Variant::STRING, PROPERTY_HINT_ENUM, "interface/editor/localization/editor_language", "auto", lang_hint, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED | PROPERTY_USAGE_EDITOR_BASIC_SETTING);@@ -2045,6 +2054,13 @@ String EditorSettings::get_language() const {String best = "en";int best_score = 0;for (const String &host_lang : OS::get_singleton()->get_preferred_locales()) {+ if (host_lang.get_slicec('_', 0) == "en") {+ int score = TranslationServer::get_singleton()->compare_locales(host_lang, "en");+ if (score > 0 && score >= best_score) {+ best = "en";+ best_score = score;+ }+ }for (const String &locale : get_editor_locales()) {// Test against language code without regional variants (e.g. ur_PK).String lang_code = locale.get_slicec('_', 0);