mirror of
https://github.com/godotengine/godot.git
synced 2025-12-07 22:00:10 +00:00
Editor: Generate translation data in separate cpp files
This commit is contained in:
parent
adb2ec043e
commit
c93f55533d
2 changed files with 33 additions and 37 deletions
|
|
@ -68,8 +68,10 @@ inline constexpr const unsigned char _doc_data_compressed[] = {{
|
|||
""")
|
||||
|
||||
|
||||
def make_translations_header(target, source, env):
|
||||
category = os.path.basename(str(target[0])).split("_")[0]
|
||||
def make_translations(target, source, env):
|
||||
target_h, target_cpp = str(target[0]), str(target[1])
|
||||
|
||||
category = os.path.basename(target_h).split("_")[0]
|
||||
sorted_paths = sorted([src.abspath for src in source], key=lambda path: os.path.splitext(os.path.basename(path))[0])
|
||||
|
||||
xl_names = []
|
||||
|
|
@ -77,7 +79,7 @@ def make_translations_header(target, source, env):
|
|||
if not msgfmt:
|
||||
methods.print_warning("msgfmt not found, using .po files instead of .mo")
|
||||
|
||||
with methods.generated_wrapper(str(target[0])) as file:
|
||||
with methods.generated_wrapper(target_cpp) as file:
|
||||
for path in sorted_paths:
|
||||
name = os.path.splitext(os.path.basename(path))[0]
|
||||
# msgfmt erases non-translated messages, so avoid using it if exporting the POT.
|
||||
|
|
@ -120,14 +122,9 @@ inline constexpr const unsigned char _{category}_translation_{name}_compressed[]
|
|||
xl_names.append([name, len(buffer), decomp_size])
|
||||
|
||||
file.write(f"""\
|
||||
struct {category.capitalize()}TranslationList {{
|
||||
const char* lang;
|
||||
int comp_size;
|
||||
int uncomp_size;
|
||||
const unsigned char* data;
|
||||
}};
|
||||
#include "{target_h}"
|
||||
|
||||
inline constexpr {category.capitalize()}TranslationList _{category}_translations[] = {{
|
||||
const {category.capitalize()}TranslationList _{category}_translations[] = {{
|
||||
""")
|
||||
|
||||
for x in xl_names:
|
||||
|
|
@ -136,4 +133,16 @@ inline constexpr {category.capitalize()}TranslationList _{category}_translations
|
|||
file.write("""\
|
||||
{ nullptr, 0, 0, nullptr },
|
||||
};
|
||||
""")
|
||||
|
||||
with methods.generated_wrapper(target_h) as file:
|
||||
file.write(f"""\
|
||||
struct {category.capitalize()}TranslationList {{
|
||||
const char* lang;
|
||||
int comp_size;
|
||||
int uncomp_size;
|
||||
const unsigned char* data;
|
||||
}};
|
||||
|
||||
extern const {category.capitalize()}TranslationList _{category}_translations[];
|
||||
""")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue