From 4857648a16585bbd0fb2fbc33d3d0f768b8223b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Wed, 18 Mar 2020 18:34:36 +0100 Subject: i18n: Add support for translating the class reference - Parse `.po` files from `doc/translations/*.po` like already done with `editor/translations/*.po`. - Add logic to register a doc translation mapping in `TranslationServer` and `EditorSettings`. - Add `DTR()` to lookup the doc translation mapping (similar to `TTR()`). Strings are automatically dedented and stripped of whitespace to ensure that they would match the translation catalog. - Use `DTR()` to translate relevant strings in `EditorHelp`, `EditorInspector`, `CreateDialog`, `ConnectionsDialog`. - Small simplification to `TranslationLoaderPO`, the path argument was not really meaningful. --- core/ustring.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'core/ustring.cpp') diff --git a/core/ustring.cpp b/core/ustring.cpp index da089dce40..8027ae29b5 100644 --- a/core/ustring.cpp +++ b/core/ustring.cpp @@ -4412,7 +4412,6 @@ String String::unquote() const { #ifdef TOOLS_ENABLED String TTR(const String &p_text) { - if (TranslationServer::get_singleton()) { return TranslationServer::get_singleton()->tool_translate(p_text); } @@ -4420,10 +4419,18 @@ String TTR(const String &p_text) { return p_text; } +String DTR(const String &p_text) { + 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; +} #endif String RTR(const String &p_text) { - if (TranslationServer::get_singleton()) { String rtr = TranslationServer::get_singleton()->tool_translate(p_text); if (rtr == String() || rtr == p_text) { -- cgit v1.2.3