From 089b797dc8ca549591fcb61678a36481f8969b07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pa=CC=84vels=20Nadtoc=CC=8Cajevs?= <7645683+bruvzg@users.noreply.github.com> Date: Sun, 21 Jun 2026 21:41:10 +0300 Subject: [PATCH] [Editor] Fix multiple issues with preferred locale list. Fix locales added multiple times to the language selector list. Fix automatic locale selection if English is the first of multiple preferred locales. --- editor/settings/editor_settings.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/editor/settings/editor_settings.cpp b/editor/settings/editor_settings.cpp index 1e39004fd2..a416b14859 100644 --- a/editor/settings/editor_settings.cpp +++ b/editor/settings/editor_settings.cpp @@ -424,10 +424,16 @@ void EditorSettings::_load_defaults(Ref 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 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 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);