summaryrefslogtreecommitdiff
path: root/editor
diff options
context:
space:
mode:
Diffstat (limited to 'editor')
-rw-r--r--editor/SCsub11
-rw-r--r--editor/connections_dialog.cpp2
-rw-r--r--editor/create_dialog.cpp4
-rw-r--r--editor/editor_builders.py23
-rw-r--r--editor/editor_help.cpp19
-rw-r--r--editor/editor_inspector.cpp6
-rw-r--r--editor/editor_settings.cpp34
7 files changed, 67 insertions, 32 deletions
diff --git a/editor/SCsub b/editor/SCsub
index 4431166ee6..e54383350e 100644
--- a/editor/SCsub
+++ b/editor/SCsub
@@ -66,10 +66,15 @@ if env['tools']:
path = env.Dir('.').abspath
- # Translations
+ # Editor translations
tlist = glob.glob(path + "/translations/*.po")
- env.Depends('#editor/translations.gen.h', tlist)
- env.CommandNoCache('#editor/translations.gen.h', tlist, run_in_subprocess(editor_builders.make_translations_header))
+ env.Depends('#editor/editor_translations.gen.h', tlist)
+ env.CommandNoCache('#editor/editor_translations.gen.h', tlist, run_in_subprocess(editor_builders.make_editor_translations_header))
+
+ # Documentation translations
+ tlist = glob.glob(env.Dir("#doc").abspath + "/translations/*.po")
+ env.Depends('#editor/doc_translations.gen.h', tlist)
+ env.CommandNoCache('#editor/doc_translations.gen.h', tlist, run_in_subprocess(editor_builders.make_doc_translations_header))
# Fonts
flist = glob.glob(path + "/../thirdparty/fonts/*.ttf")
diff --git a/editor/connections_dialog.cpp b/editor/connections_dialog.cpp
index 23df649851..60a15984ee 100644
--- a/editor/connections_dialog.cpp
+++ b/editor/connections_dialog.cpp
@@ -992,7 +992,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 = F->get().signals[i].description.strip_edges();
+ descr = DTR(F->get().signals[i].description.strip_edges());
break;
}
}
diff --git a/editor/create_dialog.cpp b/editor/create_dialog.cpp
index 3e09a9a760..b220e82f6c 100644
--- a/editor/create_dialog.cpp
+++ b/editor/create_dialog.cpp
@@ -248,7 +248,7 @@ void CreateDialog::add_type(const String &p_type, HashMap<String, TreeItem *> &p
item->set_collapsed(collapse);
}
- const String &description = EditorHelp::get_doc_data()->class_list[p_type].brief_description;
+ const String &description = DTR(EditorHelp::get_doc_data()->class_list[p_type].brief_description);
item->set_tooltip(0, description);
item->set_icon(0, EditorNode::get_singleton()->get_class_icon(p_type, base_type));
@@ -556,7 +556,7 @@ void CreateDialog::_item_selected() {
if (!EditorHelp::get_doc_data()->class_list.has(name))
return;
- help_bit->set_text(EditorHelp::get_doc_data()->class_list[name].brief_description);
+ help_bit->set_text(DTR(EditorHelp::get_doc_data()->class_list[name].brief_description));
get_ok()->set_disabled(false);
}
diff --git a/editor/editor_builders.py b/editor/editor_builders.py
index 910c53e2ff..e8c23acf9e 100644
--- a/editor/editor_builders.py
+++ b/editor/editor_builders.py
@@ -73,15 +73,15 @@ def make_fonts_header(target, source, env):
g.close()
-def make_translations_header(target, source, env):
+def make_translations_header(target, source, env, category):
dst = target[0]
g = open_utf8(dst, "w")
g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n")
- g.write("#ifndef _EDITOR_TRANSLATIONS_H\n")
- g.write("#define _EDITOR_TRANSLATIONS_H\n")
+ g.write("#ifndef _{}_TRANSLATIONS_H\n".format(category.upper()))
+ g.write("#define _{}_TRANSLATIONS_H\n".format(category.upper()))
import zlib
import os.path
@@ -96,7 +96,7 @@ def make_translations_header(target, source, env):
buf = zlib.compress(buf)
name = os.path.splitext(os.path.basename(sorted_paths[i]))[0]
- g.write("static const unsigned char _translation_" + name + "_compressed[] = {\n")
+ g.write("static const unsigned char _{}_translation_{}_compressed[] = {{\n".format(category, name))
for j in range(len(buf)):
g.write("\t" + byte_to_str(buf[j]) + ",\n")
@@ -104,15 +104,15 @@ def make_translations_header(target, source, env):
xl_names.append([name, len(buf), str(decomp_size)])
- g.write("struct EditorTranslationList {\n")
+ g.write("struct {}TranslationList {{\n".format(category.capitalize()))
g.write("\tconst char* lang;\n")
g.write("\tint comp_size;\n")
g.write("\tint uncomp_size;\n")
g.write("\tconst unsigned char* data;\n")
g.write("};\n\n")
- g.write("static EditorTranslationList _editor_translations[] = {\n")
+ g.write("static {}TranslationList _{}_translations[] = {{\n".format(category.capitalize(), category))
for x in xl_names:
- g.write("\t{ \"" + x[0] + "\", " + str(x[1]) + ", " + str(x[2]) + ", _translation_" + x[0] + "_compressed},\n")
+ g.write("\t{{ \"{}\", {}, {}, _{}_translation_{}_compressed }},\n".format(x[0], str(x[1]), str(x[2]), category, x[0]))
g.write("\t{NULL, 0, 0, NULL}\n")
g.write("};\n")
@@ -120,5 +120,14 @@ def make_translations_header(target, source, env):
g.close()
+
+def make_editor_translations_header(target, source, env):
+ make_translations_header(target, source, env, "editor")
+
+
+def make_doc_translations_header(target, source, env):
+ make_translations_header(target, source, env, "doc")
+
+
if __name__ == '__main__':
subprocess_main(globals())
diff --git a/editor/editor_help.cpp b/editor/editor_help.cpp
index 4526a3a52c..874f984844 100644
--- a/editor/editor_help.cpp
+++ b/editor/editor_help.cpp
@@ -433,7 +433,7 @@ void EditorHelp::_update_doc() {
class_desc->push_color(text_color);
class_desc->push_font(doc_bold_font);
class_desc->push_indent(1);
- _add_text(cd.brief_description);
+ _add_text(DTR(cd.brief_description));
class_desc->pop();
class_desc->pop();
class_desc->pop();
@@ -458,7 +458,7 @@ void EditorHelp::_update_doc() {
class_desc->push_color(text_color);
class_desc->push_font(doc_font);
class_desc->push_indent(1);
- _add_text(cd.description);
+ _add_text(DTR(cd.description));
class_desc->pop();
class_desc->pop();
class_desc->pop();
@@ -480,7 +480,7 @@ void EditorHelp::_update_doc() {
class_desc->add_newline();
for (int i = 0; i < cd.tutorials.size(); i++) {
- const String link = cd.tutorials[i];
+ const String link = DTR(cd.tutorials[i]);
String linktxt = link;
const int seppos = linktxt.find("//");
if (seppos != -1) {
@@ -726,7 +726,7 @@ void EditorHelp::_update_doc() {
class_desc->push_font(doc_font);
class_desc->add_text(" ");
class_desc->push_color(comment_color);
- _add_text(cd.theme_properties[i].description);
+ _add_text(DTR(cd.theme_properties[i].description));
class_desc->pop();
class_desc->pop();
}
@@ -796,7 +796,7 @@ void EditorHelp::_update_doc() {
class_desc->push_font(doc_font);
class_desc->push_color(comment_color);
class_desc->push_indent(1);
- _add_text(cd.signals[i].description);
+ _add_text(DTR(cd.signals[i].description));
class_desc->pop(); // indent
class_desc->pop();
class_desc->pop(); // font
@@ -893,7 +893,7 @@ void EditorHelp::_update_doc() {
//class_desc->add_text(" ");
class_desc->push_indent(1);
class_desc->push_color(comment_color);
- _add_text(enum_list[i].description);
+ _add_text(DTR(enum_list[i].description));
class_desc->pop();
class_desc->pop();
class_desc->pop(); // indent
@@ -959,7 +959,7 @@ void EditorHelp::_update_doc() {
class_desc->push_font(doc_font);
class_desc->push_indent(1);
class_desc->push_color(comment_color);
- _add_text(constants[i].description);
+ _add_text(DTR(constants[i].description));
class_desc->pop();
class_desc->pop();
class_desc->pop(); // indent
@@ -1070,7 +1070,7 @@ void EditorHelp::_update_doc() {
class_desc->push_font(doc_font);
class_desc->push_indent(1);
if (cd.properties[i].description.strip_edges() != String()) {
- _add_text(cd.properties[i].description);
+ _add_text(DTR(cd.properties[i].description));
} else {
class_desc->add_image(get_icon("Error", "EditorIcons"));
class_desc->add_text(" ");
@@ -1123,7 +1123,7 @@ void EditorHelp::_update_doc() {
class_desc->push_font(doc_font);
class_desc->push_indent(1);
if (methods_filtered[i].description.strip_edges() != String()) {
- _add_text(methods_filtered[i].description);
+ _add_text(DTR(methods_filtered[i].description));
} else {
class_desc->add_image(get_icon("Error", "EditorIcons"));
class_desc->add_text(" ");
@@ -1449,7 +1449,6 @@ static void _add_text_to_rt(const String &p_bbcode, RichTextLabel *p_rt) {
}
void EditorHelp::_add_text(const String &p_bbcode) {
-
_add_text_to_rt(p_bbcode, class_desc);
}
diff --git a/editor/editor_inspector.cpp b/editor/editor_inspector.cpp
index fe3ed23dee..be3ee397e8 100644
--- a/editor/editor_inspector.cpp
+++ b/editor/editor_inspector.cpp
@@ -1551,7 +1551,7 @@ void EditorInspector::update_tree() {
if (E) {
descr = E->get().brief_description;
}
- class_descr_cache[type2] = descr;
+ class_descr_cache[type2] = DTR(descr);
}
category->set_tooltip(p.name + "::" + (class_descr_cache[type2] == "" ? "" : class_descr_cache[type2]));
@@ -1703,7 +1703,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 = F->get().properties[i].description.strip_edges();
+ descr = DTR(F->get().properties[i].description.strip_edges());
break;
}
}
@@ -1713,7 +1713,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 = F->get().theme_properties[i].description.strip_edges();
+ descr = DTR(F->get().theme_properties[i].description.strip_edges());
break;
}
}
diff --git a/editor/editor_settings.cpp b/editor/editor_settings.cpp
index 3f54761c15..a32b736851 100644
--- a/editor/editor_settings.cpp
+++ b/editor/editor_settings.cpp
@@ -44,8 +44,9 @@
#include "core/os/os.h"
#include "core/project_settings.h"
#include "core/version.h"
+#include "editor/doc_translations.gen.h"
#include "editor/editor_node.h"
-#include "editor/translations.gen.h"
+#include "editor/editor_translations.gen.h"
#include "scene/main/node.h"
#include "scene/main/scene_tree.h"
#include "scene/main/viewport.h"
@@ -982,14 +983,12 @@ void EditorSettings::setup_language() {
String lang = get("interface/editor/editor_language");
if (lang == "en")
- return; //none to do
+ return; // Default, nothing to do.
+ // Load editor translation for configured/detected locale.
EditorTranslationList *etl = _editor_translations;
-
while (etl->data) {
-
if (etl->lang == lang) {
-
Vector<uint8_t> data;
data.resize(etl->uncomp_size);
Compression::decompress(data.ptrw(), etl->uncomp_size, etl->data, etl->comp_size, Compression::MODE_DEFLATE);
@@ -997,7 +996,7 @@ void EditorSettings::setup_language() {
FileAccessMemory *fa = memnew(FileAccessMemory);
fa->open_custom(data.ptr(), data.size());
- Ref<Translation> tr = TranslationLoaderPO::load_translation(fa, NULL, "translation_" + String(etl->lang));
+ Ref<Translation> tr = TranslationLoaderPO::load_translation(fa);
if (tr.is_valid()) {
tr->set_locale(etl->lang);
@@ -1008,6 +1007,29 @@ void EditorSettings::setup_language() {
etl++;
}
+
+ // Load class reference translation.
+ DocTranslationList *dtl = _doc_translations;
+ while (dtl->data) {
+ if (dtl->lang == lang) {
+ Vector<uint8_t> data;
+ data.resize(dtl->uncomp_size);
+ Compression::decompress(data.ptrw(), dtl->uncomp_size, dtl->data, dtl->comp_size, Compression::MODE_DEFLATE);
+
+ FileAccessMemory *fa = memnew(FileAccessMemory);
+ fa->open_custom(data.ptr(), data.size());
+
+ Ref<Translation> tr = TranslationLoaderPO::load_translation(fa);
+
+ if (tr.is_valid()) {
+ tr->set_locale(dtl->lang);
+ TranslationServer::get_singleton()->set_doc_translation(tr);
+ break;
+ }
+ }
+
+ dtl++;
+ }
}
void EditorSettings::setup_network() {