You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-22 15:06:45 +00:00
Make editor language setting default to Auto
This commit is contained in:
@@ -96,6 +96,12 @@
|
|||||||
Returns the edited (current) scene's root [Node].
|
Returns the edited (current) scene's root [Node].
|
||||||
</description>
|
</description>
|
||||||
</method>
|
</method>
|
||||||
|
<method name="get_editor_language" qualifiers="const">
|
||||||
|
<return type="String" />
|
||||||
|
<description>
|
||||||
|
Returns the language currently used for the editor interface.
|
||||||
|
</description>
|
||||||
|
</method>
|
||||||
<method name="get_editor_main_screen" qualifiers="const">
|
<method name="get_editor_main_screen" qualifiers="const">
|
||||||
<return type="VBoxContainer" />
|
<return type="VBoxContainer" />
|
||||||
<description>
|
<description>
|
||||||
|
|||||||
@@ -880,7 +880,7 @@
|
|||||||
During a drag-and-drop, this is how long to wait over a UI element before it triggers a reaction (e.g. a section unfolds to show nested items).
|
During a drag-and-drop, this is how long to wait over a UI element before it triggers a reaction (e.g. a section unfolds to show nested items).
|
||||||
</member>
|
</member>
|
||||||
<member name="interface/editor/editor_language" type="String" setter="" getter="">
|
<member name="interface/editor/editor_language" type="String" setter="" getter="">
|
||||||
The language to use for the editor interface.
|
The language to use for the editor interface. If set to [b]Auto[/b], the language is automatically determined based on the system locale. See also [method EditorInterface.get_editor_language].
|
||||||
Translations are provided by the community. If you spot a mistake, [url=https://contributing.godotengine.org/en/latest/documentation/translation/index.html]contribute to editor translations on Weblate![/url]
|
Translations are provided by the community. If you spot a mistake, [url=https://contributing.godotengine.org/en/latest/documentation/translation/index.html]contribute to editor translations on Weblate![/url]
|
||||||
</member>
|
</member>
|
||||||
<member name="interface/editor/editor_screen" type="int" setter="" getter="">
|
<member name="interface/editor/editor_screen" type="int" setter="" getter="">
|
||||||
|
|||||||
@@ -442,6 +442,10 @@ float EditorInterface::get_editor_scale() const {
|
|||||||
return EDSCALE;
|
return EDSCALE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String EditorInterface::get_editor_language() const {
|
||||||
|
return EditorSettings::get_singleton()->get_language();
|
||||||
|
}
|
||||||
|
|
||||||
bool EditorInterface::is_node_3d_snap_enabled() const {
|
bool EditorInterface::is_node_3d_snap_enabled() const {
|
||||||
return Node3DEditor::get_singleton()->is_snap_enabled();
|
return Node3DEditor::get_singleton()->is_snap_enabled();
|
||||||
}
|
}
|
||||||
@@ -846,6 +850,7 @@ void EditorInterface::_bind_methods() {
|
|||||||
ClassDB::bind_method(D_METHOD("is_multi_window_enabled"), &EditorInterface::is_multi_window_enabled);
|
ClassDB::bind_method(D_METHOD("is_multi_window_enabled"), &EditorInterface::is_multi_window_enabled);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("get_editor_scale"), &EditorInterface::get_editor_scale);
|
ClassDB::bind_method(D_METHOD("get_editor_scale"), &EditorInterface::get_editor_scale);
|
||||||
|
ClassDB::bind_method(D_METHOD("get_editor_language"), &EditorInterface::get_editor_language);
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("is_node_3d_snap_enabled"), &EditorInterface::is_node_3d_snap_enabled);
|
ClassDB::bind_method(D_METHOD("is_node_3d_snap_enabled"), &EditorInterface::is_node_3d_snap_enabled);
|
||||||
ClassDB::bind_method(D_METHOD("get_node_3d_translate_snap"), &EditorInterface::get_node_3d_translate_snap);
|
ClassDB::bind_method(D_METHOD("get_node_3d_translate_snap"), &EditorInterface::get_node_3d_translate_snap);
|
||||||
|
|||||||
@@ -131,6 +131,7 @@ public:
|
|||||||
bool is_multi_window_enabled() const;
|
bool is_multi_window_enabled() const;
|
||||||
|
|
||||||
float get_editor_scale() const;
|
float get_editor_scale() const;
|
||||||
|
String get_editor_language() const;
|
||||||
|
|
||||||
bool is_node_3d_snap_enabled() const;
|
bool is_node_3d_snap_enabled() const;
|
||||||
real_t get_node_3d_translate_snap() const;
|
real_t get_node_3d_translate_snap() const;
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ EditorPropertyNameProcessor::Style EditorPropertyNameProcessor::get_tooltip_styl
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool EditorPropertyNameProcessor::is_localization_available() {
|
bool EditorPropertyNameProcessor::is_localization_available() {
|
||||||
return EditorSettings::get_singleton() && EDITOR_GET("interface/editor/editor_language") != "en";
|
return EditorSettings::get_singleton() && EditorSettings::get_singleton()->get_language() != "en";
|
||||||
}
|
}
|
||||||
|
|
||||||
String EditorPropertyNameProcessor::_capitalize_name(const String &p_name) const {
|
String EditorPropertyNameProcessor::_capitalize_name(const String &p_name) const {
|
||||||
|
|||||||
@@ -363,6 +363,28 @@ void EditorSettings::_set_initialized() {
|
|||||||
initialized = true;
|
initialized = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static LocalVector<String> _get_skipped_locales() {
|
||||||
|
// Skip locales if Text server lack required features.
|
||||||
|
LocalVector<String> locales_to_skip;
|
||||||
|
if (!TS->has_feature(TextServer::FEATURE_BIDI_LAYOUT) || !TS->has_feature(TextServer::FEATURE_SHAPING)) {
|
||||||
|
locales_to_skip.push_back("ar"); // Arabic.
|
||||||
|
locales_to_skip.push_back("fa"); // Persian.
|
||||||
|
locales_to_skip.push_back("ur"); // Urdu.
|
||||||
|
}
|
||||||
|
if (!TS->has_feature(TextServer::FEATURE_BIDI_LAYOUT)) {
|
||||||
|
locales_to_skip.push_back("he"); // Hebrew.
|
||||||
|
}
|
||||||
|
if (!TS->has_feature(TextServer::FEATURE_SHAPING)) {
|
||||||
|
locales_to_skip.push_back("bn"); // Bengali.
|
||||||
|
locales_to_skip.push_back("hi"); // Hindi.
|
||||||
|
locales_to_skip.push_back("ml"); // Malayalam.
|
||||||
|
locales_to_skip.push_back("si"); // Sinhala.
|
||||||
|
locales_to_skip.push_back("ta"); // Tamil.
|
||||||
|
locales_to_skip.push_back("te"); // Telugu.
|
||||||
|
}
|
||||||
|
return locales_to_skip;
|
||||||
|
}
|
||||||
|
|
||||||
void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
||||||
_THREAD_SAFE_METHOD_
|
_THREAD_SAFE_METHOD_
|
||||||
// Sets up the editor setting with a default value and hint PropertyInfo.
|
// Sets up the editor setting with a default value and hint PropertyInfo.
|
||||||
@@ -381,36 +403,18 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
|||||||
/* Languages */
|
/* Languages */
|
||||||
|
|
||||||
{
|
{
|
||||||
String lang_hint = ";en/[en] English";
|
String lang_hint;
|
||||||
String host_lang = OS::get_singleton()->get_locale();
|
const String host_lang = OS::get_singleton()->get_locale();
|
||||||
|
|
||||||
// Skip locales if Text server lack required features.
|
|
||||||
Vector<String> locales_to_skip;
|
|
||||||
if (!TS->has_feature(TextServer::FEATURE_BIDI_LAYOUT) || !TS->has_feature(TextServer::FEATURE_SHAPING)) {
|
|
||||||
locales_to_skip.push_back("ar"); // Arabic
|
|
||||||
locales_to_skip.push_back("fa"); // Persian
|
|
||||||
locales_to_skip.push_back("ur"); // Urdu
|
|
||||||
}
|
|
||||||
if (!TS->has_feature(TextServer::FEATURE_BIDI_LAYOUT)) {
|
|
||||||
locales_to_skip.push_back("he"); // Hebrew
|
|
||||||
}
|
|
||||||
if (!TS->has_feature(TextServer::FEATURE_SHAPING)) {
|
|
||||||
locales_to_skip.push_back("bn"); // Bengali
|
|
||||||
locales_to_skip.push_back("hi"); // Hindi
|
|
||||||
locales_to_skip.push_back("ml"); // Malayalam
|
|
||||||
locales_to_skip.push_back("si"); // Sinhala
|
|
||||||
locales_to_skip.push_back("ta"); // Tamil
|
|
||||||
locales_to_skip.push_back("te"); // Telugu
|
|
||||||
}
|
|
||||||
|
|
||||||
|
// Skip locales which we can't render properly.
|
||||||
|
const LocalVector<String> locales_to_skip = _get_skipped_locales();
|
||||||
if (!locales_to_skip.is_empty()) {
|
if (!locales_to_skip.is_empty()) {
|
||||||
WARN_PRINT("Some locales are not properly supported by selected Text Server and are disabled.");
|
WARN_PRINT("Some locales are not properly supported by selected Text Server and are disabled.");
|
||||||
}
|
}
|
||||||
|
|
||||||
String best;
|
String best = "en";
|
||||||
int best_score = 0;
|
int best_score = 0;
|
||||||
for (const String &locale : get_editor_locales()) {
|
for (const String &locale : get_editor_locales()) {
|
||||||
// Skip locales which we can't render properly (see above comment).
|
|
||||||
// Test against language code without regional variants (e.g. ur_PK).
|
// Test against language code without regional variants (e.g. ur_PK).
|
||||||
String lang_code = locale.get_slicec('_', 0);
|
String lang_code = locale.get_slicec('_', 0);
|
||||||
if (locales_to_skip.has(lang_code)) {
|
if (locales_to_skip.has(lang_code)) {
|
||||||
@@ -427,11 +431,9 @@ void EditorSettings::_load_defaults(Ref<ConfigFile> p_extra_config) {
|
|||||||
best_score = score;
|
best_score = score;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (best_score == 0) {
|
lang_hint = vformat(";auto/Auto (%s);en/[en] English", TranslationServer::get_singleton()->get_locale_name(best)) + lang_hint;
|
||||||
best = "en";
|
|
||||||
}
|
|
||||||
|
|
||||||
EDITOR_SETTING_USAGE(Variant::STRING, PROPERTY_HINT_ENUM, "interface/editor/editor_language", best, lang_hint, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED | PROPERTY_USAGE_EDITOR_BASIC_SETTING);
|
EDITOR_SETTING_USAGE(Variant::STRING, PROPERTY_HINT_ENUM, "interface/editor/editor_language", "auto", lang_hint, PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESTART_IF_CHANGED | PROPERTY_USAGE_EDITOR_BASIC_SETTING);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Asset library
|
// Asset library
|
||||||
@@ -1329,7 +1331,7 @@ fail:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EditorSettings::setup_language(bool p_initial_setup) {
|
void EditorSettings::setup_language(bool p_initial_setup) {
|
||||||
String lang = _EDITOR_GET("interface/editor/editor_language");
|
String lang = get_language();
|
||||||
if (p_initial_setup) {
|
if (p_initial_setup) {
|
||||||
String lang_ov = Main::get_locale_override();
|
String lang_ov = Main::get_locale_override();
|
||||||
if (!lang_ov.is_empty()) {
|
if (!lang_ov.is_empty()) {
|
||||||
@@ -1851,6 +1853,37 @@ float EditorSettings::get_auto_display_scale() {
|
|||||||
#endif // defined(MACOS_ENABLED) || defined(ANDROID_ENABLED)
|
#endif // defined(MACOS_ENABLED) || defined(ANDROID_ENABLED)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String EditorSettings::get_language() const {
|
||||||
|
const String language = has_setting("interface/editor/editor_language") ? get("interface/editor/editor_language") : "auto";
|
||||||
|
if (language != "auto") {
|
||||||
|
return language;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (auto_language.is_empty()) {
|
||||||
|
// Skip locales which we can't render properly.
|
||||||
|
const LocalVector<String> locales_to_skip = _get_skipped_locales();
|
||||||
|
const String host_lang = OS::get_singleton()->get_locale();
|
||||||
|
|
||||||
|
String best = "en";
|
||||||
|
int best_score = 0;
|
||||||
|
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);
|
||||||
|
if (locales_to_skip.has(lang_code)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int score = TranslationServer::get_singleton()->compare_locales(host_lang, locale);
|
||||||
|
if (score > 0 && score >= best_score) {
|
||||||
|
best = locale;
|
||||||
|
best_score = score;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
auto_language = best;
|
||||||
|
}
|
||||||
|
return auto_language;
|
||||||
|
}
|
||||||
|
|
||||||
// Shortcuts
|
// Shortcuts
|
||||||
|
|
||||||
void EditorSettings::_add_shortcut_default(const String &p_name, const Ref<Shortcut> &p_shortcut) {
|
void EditorSettings::_add_shortcut_default(const String &p_name, const Ref<Shortcut> &p_shortcut) {
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ private:
|
|||||||
static Ref<EditorSettings> singleton;
|
static Ref<EditorSettings> singleton;
|
||||||
|
|
||||||
HashSet<String> changed_settings;
|
HashSet<String> changed_settings;
|
||||||
|
mutable String auto_language;
|
||||||
|
|
||||||
mutable Ref<ConfigFile> project_metadata;
|
mutable Ref<ConfigFile> project_metadata;
|
||||||
HashMap<String, PropertyInfo> hints;
|
HashMap<String, PropertyInfo> hints;
|
||||||
@@ -186,6 +187,7 @@ public:
|
|||||||
Vector<String> get_script_templates(const String &p_extension, const String &p_custom_path = String());
|
Vector<String> get_script_templates(const String &p_extension, const String &p_custom_path = String());
|
||||||
String get_editor_layouts_config() const;
|
String get_editor_layouts_config() const;
|
||||||
static float get_auto_display_scale();
|
static float get_auto_display_scale();
|
||||||
|
String get_language() const;
|
||||||
|
|
||||||
void _add_shortcut_default(const String &p_name, const Ref<Shortcut> &p_shortcut);
|
void _add_shortcut_default(const String &p_name, const Ref<Shortcut> &p_shortcut);
|
||||||
void add_shortcut(const String &p_name, const Ref<Shortcut> &p_shortcut);
|
void add_shortcut(const String &p_name, const Ref<Shortcut> &p_shortcut);
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ namespace GodotTools.Build
|
|||||||
startInfo.UseShellExecute = false;
|
startInfo.UseShellExecute = false;
|
||||||
startInfo.CreateNoWindow = true;
|
startInfo.CreateNoWindow = true;
|
||||||
startInfo.EnvironmentVariables["DOTNET_CLI_UI_LANGUAGE"]
|
startInfo.EnvironmentVariables["DOTNET_CLI_UI_LANGUAGE"]
|
||||||
= ((string)editorSettings.GetSetting("interface/editor/editor_language")).Replace('_', '-');
|
= ((string)EditorInterface.Singleton.GetEditorLanguage()).Replace('_', '-');
|
||||||
|
|
||||||
if (OperatingSystem.IsWindows())
|
if (OperatingSystem.IsWindows())
|
||||||
{
|
{
|
||||||
@@ -111,7 +111,7 @@ namespace GodotTools.Build
|
|||||||
startInfo.RedirectStandardError = true;
|
startInfo.RedirectStandardError = true;
|
||||||
startInfo.UseShellExecute = false;
|
startInfo.UseShellExecute = false;
|
||||||
startInfo.EnvironmentVariables["DOTNET_CLI_UI_LANGUAGE"]
|
startInfo.EnvironmentVariables["DOTNET_CLI_UI_LANGUAGE"]
|
||||||
= ((string)editorSettings.GetSetting("interface/editor/editor_language")).Replace('_', '-');
|
= ((string)EditorInterface.Singleton.GetEditorLanguage()).Replace('_', '-');
|
||||||
|
|
||||||
if (OperatingSystem.IsWindows())
|
if (OperatingSystem.IsWindows())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user