From 81da3b8ba4fad460753f3be1b4c0a7939f12545d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Thu, 28 May 2020 12:02:12 +0200 Subject: [PATCH] Use translated docs in PropertySelector And do the dedent and stripping for both translated and non-translated strings for consistency, and so that we don't need to do it at the call site. (cherry picked from commit a16031beb616906178ba7c10d3d2fbb6ff006285) --- core/ustring.cpp | 7 ++++--- editor/connections_dialog.cpp | 2 +- editor/editor_inspector.cpp | 8 ++++---- editor/property_selector.cpp | 4 ++-- .../visual_script/visual_script_property_selector.cpp | 10 +++++----- 5 files changed, 16 insertions(+), 15 deletions(-) diff --git a/core/ustring.cpp b/core/ustring.cpp index 3d7b7a07efb..df5bf95706c 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -4470,13 +4470,14 @@ String TTR(const String &p_text) { } String DTR(const String &p_text) { + // Comes straight from the XML, so remove indentation and any trailing whitespace. + const String text = p_text.dedent().strip_edges(); + if (TranslationServer::get_singleton()) { - // Comes straight from the XML, so remove indentation and any trailing whitespace. - const String text = p_text.dedent().strip_edges(); return TranslationServer::get_singleton()->doc_translate(text); } - return p_text; + return text; } #endif diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp index 2fa897bf4c0..8c07567ec6c 100644 --- a/editor/connections_dialog.cpp +++ b/editor/connections_dialog.cpp @@ -1001,7 +1001,7 @@ void ConnectionsDock::update_tree() { while (F && descr == String()) { for (int i = 0; i < F->get().signals.size(); i++) { if (F->get().signals[i].name == signal_name.operator String()) { - descr = DTR(F->get().signals[i].description.strip_edges()); + descr = DTR(F->get().signals[i].description); break; } } diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp index a4be801ca64..88e8f9120d3 100644 --- a/editor/editor_inspector.cpp +++ b/editor/editor_inspector.cpp @@ -1488,9 +1488,9 @@ void EditorInspector::update_tree() { DocData *dd = EditorHelp::get_doc_data(); Map::Element *E = dd->class_list.find(type2); if (E) { - descr = E->get().brief_description; + descr = DTR(E->get().brief_description); } - class_descr_cache[type2] = DTR(descr); + class_descr_cache[type2] = descr; } category->set_tooltip(p.name + "::" + (class_descr_cache[type2] == "" ? "" : class_descr_cache[type2])); @@ -1645,7 +1645,7 @@ void EditorInspector::update_tree() { while (F && descr == String()) { for (int i = 0; i < F->get().properties.size(); i++) { if (F->get().properties[i].name == propname.operator String()) { - descr = DTR(F->get().properties[i].description.strip_edges()); + descr = DTR(F->get().properties[i].description); break; } } @@ -1655,7 +1655,7 @@ void EditorInspector::update_tree() { // Likely a theme property. for (int i = 0; i < F->get().theme_properties.size(); i++) { if (F->get().theme_properties[i].name == slices[1]) { - descr = DTR(F->get().theme_properties[i].description.strip_edges()); + descr = DTR(F->get().theme_properties[i].description); break; } } diff --git a/editor/property_selector.cpp b/editor/property_selector.cpp index 9264e823049..d663c683a23 100644 --- a/editor/property_selector.cpp +++ b/editor/property_selector.cpp @@ -358,7 +358,7 @@ void PropertySelector::_item_selected() { if (E) { for (int i = 0; i < E->get().properties.size(); i++) { if (E->get().properties[i].name == name) { - text = E->get().properties[i].description; + text = DTR(E->get().properties[i].description); break; } } @@ -377,7 +377,7 @@ void PropertySelector::_item_selected() { if (E) { for (int i = 0; i < E->get().methods.size(); i++) { if (E->get().methods[i].name == name) { - text = E->get().methods[i].description; + text = DTR(E->get().methods[i].description); break; } } diff --git a/modules/visual_script/visual_script_property_selector.cpp b/modules/visual_script/visual_script_property_selector.cpp index 65b6e256d39..f0e004cf6d8 100644 --- a/modules/visual_script/visual_script_property_selector.cpp +++ b/modules/visual_script/visual_script_property_selector.cpp @@ -445,7 +445,7 @@ void VisualScriptPropertySelector::_item_selected() { if (E) { for (int i = 0; i < E->get().properties.size(); i++) { if (E->get().properties[i].name == name) { - text = E->get().properties[i].description; + text = DTR(E->get().properties[i].description); } } } @@ -459,7 +459,7 @@ void VisualScriptPropertySelector::_item_selected() { if (C) { for (int i = 0; i < C->get().methods.size(); i++) { if (C->get().methods[i].name == name) { - text = C->get().methods[i].description; + text = DTR(C->get().methods[i].description); } } } @@ -472,7 +472,7 @@ void VisualScriptPropertySelector::_item_selected() { if (T) { for (int i = 0; i < T->get().methods.size(); i++) { if (T->get().methods[i].name == functions[functions.size() - 1]) { - text = T->get().methods[i].description; + text = DTR(T->get().methods[i].description); } } } @@ -491,7 +491,7 @@ void VisualScriptPropertySelector::_item_selected() { if (typecast_node.is_valid()) { Map::Element *F = dd->class_list.find(typecast_node->get_class_name()); if (F) { - text = F->get().description; + text = DTR(F->get().description); } } @@ -501,7 +501,7 @@ void VisualScriptPropertySelector::_item_selected() { if (F) { for (int i = 0; i < F->get().constants.size(); i++) { if (F->get().constants[i].value.to_int() == int(builtin_node->get_func())) { - text = F->get().constants[i].description; + text = DTR(F->get().constants[i].description); } } }