summaryrefslogtreecommitdiff
path: root/main
diff options
context:
space:
mode:
authorHaoyu Qiu <timothyqiu32@gmail.com>2021-12-15 23:01:06 +0800
committerHaoyu Qiu <timothyqiu32@gmail.com>2021-12-16 17:49:22 +0800
commite4e4e475f8f1a1d8b82ef7ad636da8536e8c6554 (patch)
tree584197a87c47a265d71a97df3fcd69d8e5a57783 /main
parentedd3ca45016a4ee8cc5f7c1108e1c71bfa2a86ab (diff)
Make `--doctool` locale aware
* Adds `indent(str)` to `String`: * Indent the (multiline) string with the given indentation. * This method is added in order to keep the translated XML correctly indented. * Moves the loading of tool/doc translation into `editor/editor_translation.{h,cpp}`. * This will be used from both `EditorSettings` and the doc tool from `main`. * Makes use of doc translation when generating XML class references, and setup the translation locale based on `-l LOCALE` CLI parameter. The XML class reference won't be translated if `-l LOCALE` parameter is not given, or when it's `-l en`.
Diffstat (limited to 'main')
-rw-r--r--main/main.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/main/main.cpp b/main/main.cpp
index 6cc877f8c2..21e5935adc 100644
--- a/main/main.cpp
+++ b/main/main.cpp
@@ -83,6 +83,7 @@
#include "editor/doc_tools.h"
#include "editor/editor_node.h"
#include "editor/editor_settings.h"
+#include "editor/editor_translation.h"
#include "editor/progress_dialog.h"
#include "editor/project_manager.h"
#ifndef NO_EDITOR_SPLASH
@@ -1937,7 +1938,6 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
}
_start_success = true;
- locale = String();
ClassDB::set_current_api(ClassDB::API_NONE); //no more APIs are registered at this point
@@ -2049,6 +2049,11 @@ bool Main::start() {
// Needed to instance editor-only classes for their default values
Engine::get_singleton()->set_editor_hint(true);
+ // Translate the class reference only when `-l LOCALE` parameter is given.
+ if (!locale.is_empty() && locale != "en") {
+ load_doc_translations(locale);
+ }
+
{
DirAccessRef da = DirAccess::open(doc_tool_path);
ERR_FAIL_COND_V_MSG(!da, false, "Argument supplied to --doctool must be a valid directory path.");