From 8d1cb7e74cabdbeffbb827f386e6b04249295f42 Mon Sep 17 00:00:00 2001 From: Haoyu Qiu Date: Tue, 16 Apr 2024 10:34:14 +0800 Subject: [PATCH] Add project setting for root node auto translate mode --- core/config/project_settings.cpp | 1 + doc/classes/Node.xml | 4 ++-- doc/classes/ProjectSettings.xml | 4 ++++ scene/main/scene_tree.cpp | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 75eea2ef5048..104b17961d6c 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1528,6 +1528,7 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF_RST("internationalization/rendering/force_right_to_left_layout_direction", false); GLOBAL_DEF_BASIC(PropertyInfo(Variant::INT, "internationalization/rendering/root_node_layout_direction", PROPERTY_HINT_ENUM, "Based on Application Locale,Left-to-Right,Right-to-Left,Based on System Locale"), 0); + GLOBAL_DEF_BASIC("internationalization/rendering/root_node_auto_translate", true); GLOBAL_DEF(PropertyInfo(Variant::INT, "gui/timers/incremental_search_max_interval_msec", PROPERTY_HINT_RANGE, "0,10000,1,or_greater"), 2000); diff --git a/doc/classes/Node.xml b/doc/classes/Node.xml index aea4082dbec2..37e64da8c8d3 100644 --- a/doc/classes/Node.xml +++ b/doc/classes/Node.xml @@ -970,8 +970,8 @@ - Defines if any text should automatically change to its translated version depending on the current locale (for nodes such as [Label], [RichTextLabel], [Window], etc.). See [enum AutoTranslateMode]. - Also decides if the node's strings should be parsed for POT generation. + Defines if any text should automatically change to its translated version depending on the current locale (for nodes such as [Label], [RichTextLabel], [Window], etc.). Also decides if the node's strings should be parsed for POT generation. + [b]Note:[/b] For the root node, auto translate mode can also be set via [member ProjectSettings.internationalization/rendering/root_node_auto_translate]. An optional description to the node. It will be displayed as a tooltip when hovering over the node in the editor's Scene dock. diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index a5aeee5bc4af..cfa8fbca2933 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1436,6 +1436,10 @@ Force layout direction and text writing direction to RTL for all controls. + + If [code]true[/code], root node will use [constant Node.AUTO_TRANSLATE_MODE_ALWAYS], otherwise [constant Node.AUTO_TRANSLATE_MODE_DISABLED] will be used. + [b]Note:[/b] This property is only read when the project starts. To change the auto translate mode at runtime, set [member Node.auto_translate_mode] of [member SceneTree.root] instead. + Root node default layout direction. diff --git a/scene/main/scene_tree.cpp b/scene/main/scene_tree.cpp index 04dd38fb5d2b..c465a3385fc5 100644 --- a/scene/main/scene_tree.cpp +++ b/scene/main/scene_tree.cpp @@ -1752,7 +1752,7 @@ SceneTree::SceneTree() { root = memnew(Window); root->set_min_size(Size2i(64, 64)); // Define a very small minimum window size to prevent bugs such as GH-37242. root->set_process_mode(Node::PROCESS_MODE_PAUSABLE); - root->set_auto_translate_mode(Node::AUTO_TRANSLATE_MODE_ALWAYS); + root->set_auto_translate_mode(GLOBAL_GET("internationalization/rendering/root_node_auto_translate") ? Node::AUTO_TRANSLATE_MODE_ALWAYS : Node::AUTO_TRANSLATE_MODE_DISABLED); root->set_name("root"); root->set_title(GLOBAL_GET("application/config/name"));