1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-07 12:30:27 +00:00

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`.
This commit is contained in:
Haoyu Qiu
2021-12-15 23:01:06 +08:00
parent edd3ca4501
commit e4e4e475f8
10 changed files with 238 additions and 63 deletions

View File

@@ -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.");