Godot Engine – Multi-platform 2D and 3D game engine
Fix incorrect TTRN usage in the editor
kobewic5c2098fe3e1
diff --git a/core/string/ustring.h b/core/string/ustring.hindex c949a846e9a..552b648eb4f 100644--- a/core/string/ustring.h+++ b/core/string/ustring.h@@ -765,6 +765,9 @@ String DTRN(const String &p_text, const String &p_text_plural, int p_n, const St// Use for C strings.#define TTRC(m_value) (m_value)+// Use for simple plural messages, i.e. with no counter in the message.+#define TPL(m_count, m_singular, m_plural) ((m_count == 1) ? (m_singular) : (m_plural))+// Use this to mark property names for editor translation.// Often for dynamic properties defined in _get_property_list().// Property names defined directly inside EDITOR_DEF, GLOBAL_DEF, and ADD_PROPERTY macros don't need this.diff --git a/editor/docks/scene_tree_dock.cpp b/editor/docks/scene_tree_dock.cppindex 66765c77c37..1a2c4711a82 100644--- a/editor/docks/scene_tree_dock.cpp+++ b/editor/docks/scene_tree_dock.cpp@@ -407,7 +407,7 @@ void SceneTreeDock::_perform_instantiate_scenes(const Vector<String> &p_files, N}EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();- undo_redo->create_action_for_history(TTRN("Instantiate Scene", "Instantiate Scenes", instances.size()), editor_data->get_current_edited_scene_history_id(), UndoRedo::MERGE_ALL);+ undo_redo->create_action_for_history(TPL(instances.size(), TTR("Instantiate Scene"), TTR("Instantiate Scenes")), editor_data->get_current_edited_scene_history_id(), UndoRedo::MERGE_ALL);undo_redo->add_do_method(editor_selection, "clear");for (int i = 0; i < instances.size(); i++) {@@ -477,7 +477,7 @@ void SceneTreeDock::_perform_create_audio_stream_players(const Vector<String> &p}EditorUndoRedoManager *undo_redo = EditorUndoRedoManager::get_singleton();- undo_redo->create_action_for_history(TTRN("Create AudioStreamPlayer", "Create AudioStreamPlayers", nodes.size()), editor_data->get_current_edited_scene_history_id());+ undo_redo->create_action_for_history(TPL(nodes.size(), TTR("Create AudioStreamPlayer"), TTR("Create AudioStreamPlayers")), editor_data->get_current_edited_scene_history_id());undo_redo->add_do_method(editor_selection, "clear");for (int i = 0; i < nodes.size(); i++) {diff --git a/editor/file_system/dependency_editor.cpp b/editor/file_system/dependency_editor.cppindex 8daf389a0ed..8518ed8a094 100644--- a/editor/file_system/dependency_editor.cpp+++ b/editor/file_system/dependency_editor.cpp@@ -460,7 +460,7 @@ void DependencyEditorOwners::_list_rmb_clicked(int p_item, const Vector2 &p_pos,}if (only_scenes_selected) {- file_options->add_icon_item(get_editor_theme_icon(SNAME("Load")), TTRN("Open Scene", "Open Scenes", selected_items.size()), FILE_MENU_OPEN);+ file_options->add_icon_item(get_editor_theme_icon(SNAME("Load")), TPL(selected_items.size(), TTRC("Open Scene"), TTRC("Open Scenes")), FILE_MENU_OPEN);} else if (selected_items.size() == 1) {file_options->add_icon_item(get_editor_theme_icon(SNAME("Load")), TTR("Open"), FILE_MENU_OPEN);} else {diff --git a/editor/scene/3d/node_3d_editor_viewport.cpp b/editor/scene/3d/node_3d_editor_viewport.cppindex 2471438954d..ac4fd97bc60 100644--- a/editor/scene/3d/node_3d_editor_viewport.cpp+++ b/editor/scene/3d/node_3d_editor_viewport.cpp@@ -6155,7 +6155,7 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variant}}- String title = TTRN("Can't drop the file...", "Can't drop the files...", files.size());+ String title = TPL(files.size(), TTR("Can't drop the file..."), TTR("Can't drop the files..."));if (!error_message.is_empty()) {_show_tooltip(title, error_message);return false;@@ -6177,18 +6177,9 @@ bool Node3DEditorViewport::can_drop_data_fw(const Point2 &p_point, const Variantpreview_node->hide();String desc = "[ul]" +- TTRN("[b]Default:[/b] Add as sibling of selected node (except when root is selected).",- "[b]Default:[/b] Add as siblings of selected node (except when root is selected).",- files.size()) +- "\n" +- TTRN("[b]Hold Shift:[/b] Add as child of selected node.",- "[b]Hold Shift:[/b] Add as children of selected node.",- files.size()) +- "\n" +- vformat(TTRN("[b]Hold %s:[/b] Add as child of root node.",- "[b]Hold %s:[/b] Add as children of root node.",- files.size()),- keycode_get_string((Key)KeyModifierMask::ALT));+ TPL(files.size(), TTR("[b]Default:[/b] Add as sibling of selected node (except when root is selected)."), TTR("[b]Default:[/b] Add as siblings of selected node (except when root is selected).")) + "\n" ++ TPL(files.size(), TTR("[b]Hold Shift:[/b] Add as child of selected node."), TTR("[b]Hold Shift:[/b] Add as children of selected node.")) + "\n" ++ vformat(TPL(files.size(), TTR("[b]Hold %s:[/b] Add as child of root node."), TTR("[b]Hold %s:[/b] Add as children of root node.")), keycode_get_string((Key)KeyModifierMask::ALT));if (files.size() > 1) {title = TTR("Dropping multiple files...");diff --git a/editor/scene/canvas_item_editor_plugin.cpp b/editor/scene/canvas_item_editor_plugin.cppindex 925caa86027..55d0f94dc08 100644--- a/editor/scene/canvas_item_editor_plugin.cpp+++ b/editor/scene/canvas_item_editor_plugin.cpp@@ -6865,7 +6865,7 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Varian}}- String title = TTRN("Can't drop the file...", "Can't drop the files...", files.size());+ String title = TPL(files.size(), TTR("Can't drop the file..."), TTR("Can't drop the files..."));if (!error_message.is_empty()) {set_hint_label(title, error_message);canvas_item_editor->update_viewport();@@ -6899,18 +6899,9 @@ bool CanvasItemEditorViewport::can_drop_data(const Point2 &p_point, const Variancanvas_item_editor->update_viewport();String desc = "[ul]" +- TTRN("[b]Default:[/b] Add as sibling of selected node (except when root is selected).",- "[b]Default:[/b] Add as siblings of selected node (except when root is selected).",- files.size()) +- "\n" +- TTRN("[b]Hold Shift:[/b] Add as child of selected node.",- "[b]Hold Shift:[/b] Add as children of selected node.",- files.size()) +- "\n" +- vformat(TTRN("[b]Hold %s:[/b] Add as child of root node.",- "[b]Hold %s:[/b] Add as children of root node.",- files.size()),- keycode_get_string((Key)KeyModifierMask::ALT));+ TPL(files.size(), TTR("[b]Default:[/b] Add as sibling of selected node (except when root is selected)."), TTR("[b]Default:[/b] Add as siblings of selected node (except when root is selected).")) + "\n" ++ TPL(files.size(), TTR("[b]Hold Shift:[/b] Add as child of selected node."), TTR("[b]Hold Shift:[/b] Add as children of selected node.")) + "\n" ++ vformat(TPL(files.size(), TTR("[b]Hold %s:[/b] Add as child of root node."), TTR("[b]Hold %s:[/b] Add as children of root node.")), keycode_get_string((Key)KeyModifierMask::ALT));if (files.size() > 1) {title = TTR("Dropping multiple files...");diff --git a/editor/scene/scene_tree_editor.cpp b/editor/scene/scene_tree_editor.cppindex 4ae4a778a5e..e2ef89cca8a 100644--- a/editor/scene/scene_tree_editor.cpp+++ b/editor/scene/scene_tree_editor.cpp@@ -642,7 +642,7 @@ void SceneTreeEditor::_update_node(Node *p_node, TreeItem *p_item, bool p_part_o}}if (num_groups >= 1) {- msg_temp += TTRN("Node is in this group:", "Node is in the following groups:", num_groups) + "\n";+ msg_temp += TPL(num_groups, TTR("Node is in this group:"), TTR("Node is in the following groups:")) + "\n";List<GroupInfo> groups;p_node->get_groups(&groups);diff --git a/editor/script/script_text_editor.cpp b/editor/script/script_text_editor.cppindex 91664cbbba0..63ae756bbf0 100644--- a/editor/script/script_text_editor.cpp+++ b/editor/script/script_text_editor.cpp@@ -2013,7 +2013,8 @@ void ScriptTextEditor::_set_drop_info_text(const Dictionary &p_info) const {}String text;- String c = keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL);+ const String ctrl_name = keycode_get_string((Key)KeyModifierMask::CMD_OR_CTRL);+ const String alt_name = keycode_get_string((Key)KeyModifierMask::ALT);bool drop_as_uid = bool(EDITOR_GET("text_editor/behavior/files/drop_preload_resources_as_uid"));String default_drop_option = drop_as_uid ? TTR("UID path") : TTR("file path");String alternate_drop_option = drop_as_uid ? TTR("file path") : TTR("UID path");@@ -2022,15 +2023,15 @@ void ScriptTextEditor::_set_drop_info_text(const Dictionary &p_info) const {if (type == "files" || type == "files_and_dirs" || type == "resource") {Array files = p_info.get("files", Array());- text = TTRN("Drop file path.", "Drop file paths.", files.size()) +- "\n" + vformat(TTRN("Hold %s: Add const preload by %s.", "Hold %s: Add const preloads by %s.", files.size()), c, default_drop_option) +- "\n" + vformat(TTRN("Hold %s+Shift: Add const preload by %s.", "Hold %s+Shift: Add const preloads by %s.", files.size()), c, alternate_drop_option) +- "\n" + vformat(TTRN("Hold %s: Add @export var pointing to the resource.", "Hold %s: Add @export vars pointing to the resources.", files.size()), keycode_get_string((Key)KeyModifierMask::ALT));+ text = TPL(files.size(), TTR("Drop file path."), TTR("Drop file paths.")) ++ "\n" + vformat(TPL(files.size(), TTR("Hold %s: Add const preload by %s."), TTR("Hold %s: Add const preloads by %s.")), ctrl_name, default_drop_option) ++ "\n" + vformat(TPL(files.size(), TTR("Hold %s+Shift: Add const preload by %s."), TTR("Hold %s+Shift: Add const preloads by %s.")), ctrl_name, alternate_drop_option) ++ "\n" + vformat(TPL(files.size(), TTR("Hold %s: Add @export var pointing to the resource."), TTR("Hold %s: Add @export vars pointing to the resources.")), alt_name);} else if (type == "nodes") {Array nodes = p_info["nodes"];- text = TTRN("Drop node path.", "Drop node paths.", nodes.size()) +- "\n" + vformat(TTRN("Hold %s: Add @onready var pointing to the node path.", "Hold %s: Add @onready vars pointing to the node paths.", nodes.size()), c) +- "\n" + vformat(TTRN("Hold %s: Add @export var pointing to the node.", "Hold %s: Add @export vars pointing to the nodes.", nodes.size()), keycode_get_string((Key)KeyModifierMask::ALT));+ text = TPL(nodes.size(), TTR("Drop node path."), TTR("Drop node paths.")) ++ "\n" + vformat(TPL(nodes.size(), TTR("Hold %s: Add @onready var pointing to the node path."), TTR("Hold %s: Add @onready vars pointing to the node paths.")), ctrl_name) ++ "\n" + vformat(TPL(nodes.size(), TTR("Hold %s: Add @export var pointing to the node."), TTR("Hold %s: Add @export vars pointing to the nodes.")), alt_name);} else if (type == "obj_property") {text = TTR("Drop property path.");}