1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-12 13:20:55 +00:00

Fix POT generation missing some strings when built-in ones are enabled

This commit is contained in:
Michael Alexsander
2024-03-06 16:10:23 -03:00
parent b18942d429
commit 8dba9d8330
3 changed files with 21 additions and 14 deletions

View File

@@ -61,7 +61,9 @@ def make_translations_header(target, source, env, category):
xl_names = []
for i in range(len(sorted_paths)):
if msgfmt_available:
name = os.path.splitext(os.path.basename(sorted_paths[i]))[0]
# msgfmt erases non-translated messages, so avoid using it if exporting the POT.
if msgfmt_available and name != category:
mo_path = os.path.join(tempfile.gettempdir(), uuid.uuid4().hex + ".mo")
cmd = "msgfmt " + sorted_paths[i] + " --no-hash -o " + mo_path
try:
@@ -79,7 +81,7 @@ def make_translations_header(target, source, env, category):
try:
os.remove(mo_path)
except OSError as e:
# Do not fail the entire build if it cannot delete a temporary file
# Do not fail the entire build if it cannot delete a temporary file.
print(
"WARNING: Could not delete temporary .mo file: path=%r; [%s] %s"
% (mo_path, e.__class__.__name__, e)
@@ -88,11 +90,13 @@ def make_translations_header(target, source, env, category):
with open(sorted_paths[i], "rb") as f:
buf = f.read()
if name == category:
name = "source"
decomp_size = len(buf)
# Use maximum zlib compression level to further reduce file size
# (at the cost of initial build times).
buf = zlib.compress(buf, zlib.Z_BEST_COMPRESSION)
name = os.path.splitext(os.path.basename(sorted_paths[i]))[0]
g.write("static const unsigned char _{}_translation_{}_compressed[] = {{\n".format(category, name))
for j in range(len(buf)):