summaryrefslogtreecommitdiff
path: root/editor/editor_builders.py
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2020-03-20 09:44:55 +0100
committerGitHub <noreply@github.com>2020-03-20 09:44:55 +0100
commita02c16c1d2169204adce800116cd037a6c6b755a (patch)
treef2087f5d069fe0e0dcea8d050790982a4e29113d /editor/editor_builders.py
parent87404bda8a48eafd98630a7bbe4eb80e9c9969fb (diff)
parent8c3ad2af93a119f45e0bc786ae1dfa04e116d60f (diff)
Merge pull request #37164 from akien-mga/doc-translations
i18n: Add support for translating the class reference
Diffstat (limited to 'editor/editor_builders.py')
-rw-r--r--editor/editor_builders.py23
1 files changed, 16 insertions, 7 deletions
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())