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/translation.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'core/translation.cpp') diff --git a/core/translation.cpp b/core/translation.cpp index 7399fa5619..df3661e5d0 100644 --- a/core/translation.cpp +++ b/core/translation.cpp @@ -1176,7 +1176,6 @@ void TranslationServer::setup() { set_locale(OS::get_singleton()->get_locale()); fallback = GLOBAL_DEF("locale/fallback", "en"); #ifdef TOOLS_ENABLED - { String options = ""; int idx = 0; @@ -1189,7 +1188,6 @@ void TranslationServer::setup() { ProjectSettings::get_singleton()->set_custom_property_info("locale/fallback", PropertyInfo(Variant::STRING, "locale/fallback", PROPERTY_HINT_ENUM, options)); } #endif - //load translations } void TranslationServer::set_tool_translation(const Ref &p_translation) { @@ -1197,15 +1195,26 @@ void TranslationServer::set_tool_translation(const Ref &p_translati } StringName TranslationServer::tool_translate(const StringName &p_message) const { - if (tool_translation.is_valid()) { StringName r = tool_translation->get_message(p_message); - if (r) { return r; } } + return p_message; +} +void TranslationServer::set_doc_translation(const Ref &p_translation) { + doc_translation = p_translation; +} + +StringName TranslationServer::doc_translate(const StringName &p_message) const { + if (doc_translation.is_valid()) { + StringName r = doc_translation->get_message(p_message); + if (r) { + return r; + } + } return p_message; } -- cgit v1.2.3