You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Fix POT generation missing some strings when built-in ones are enabled
This commit is contained in:
@@ -104,6 +104,7 @@ if env.editor_build:
|
|||||||
|
|
||||||
# Extractable translations
|
# Extractable translations
|
||||||
tlist = glob.glob(env.Dir("#editor/translations/extractable").abspath + "/*.po")
|
tlist = glob.glob(env.Dir("#editor/translations/extractable").abspath + "/*.po")
|
||||||
|
tlist.extend(glob.glob(env.Dir("#editor/translations/extractable").abspath + "/extractable.pot"))
|
||||||
env.Depends("#editor/extractable_translations.gen.h", tlist)
|
env.Depends("#editor/extractable_translations.gen.h", tlist)
|
||||||
env.CommandNoCache(
|
env.CommandNoCache(
|
||||||
"#editor/extractable_translations.gen.h",
|
"#editor/extractable_translations.gen.h",
|
||||||
|
|||||||
@@ -61,7 +61,9 @@ def make_translations_header(target, source, env, category):
|
|||||||
|
|
||||||
xl_names = []
|
xl_names = []
|
||||||
for i in range(len(sorted_paths)):
|
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")
|
mo_path = os.path.join(tempfile.gettempdir(), uuid.uuid4().hex + ".mo")
|
||||||
cmd = "msgfmt " + sorted_paths[i] + " --no-hash -o " + mo_path
|
cmd = "msgfmt " + sorted_paths[i] + " --no-hash -o " + mo_path
|
||||||
try:
|
try:
|
||||||
@@ -79,7 +81,7 @@ def make_translations_header(target, source, env, category):
|
|||||||
try:
|
try:
|
||||||
os.remove(mo_path)
|
os.remove(mo_path)
|
||||||
except OSError as e:
|
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(
|
print(
|
||||||
"WARNING: Could not delete temporary .mo file: path=%r; [%s] %s"
|
"WARNING: Could not delete temporary .mo file: path=%r; [%s] %s"
|
||||||
% (mo_path, e.__class__.__name__, e)
|
% (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:
|
with open(sorted_paths[i], "rb") as f:
|
||||||
buf = f.read()
|
buf = f.read()
|
||||||
|
|
||||||
|
if name == category:
|
||||||
|
name = "source"
|
||||||
|
|
||||||
decomp_size = len(buf)
|
decomp_size = len(buf)
|
||||||
# Use maximum zlib compression level to further reduce file size
|
# Use maximum zlib compression level to further reduce file size
|
||||||
# (at the cost of initial build times).
|
# (at the cost of initial build times).
|
||||||
buf = zlib.compress(buf, zlib.Z_BEST_COMPRESSION)
|
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))
|
g.write("static const unsigned char _{}_translation_{}_compressed[] = {{\n".format(category, name))
|
||||||
for j in range(len(buf)):
|
for j in range(len(buf)):
|
||||||
|
|||||||
@@ -160,6 +160,7 @@ List<StringName> get_extractable_message_list() {
|
|||||||
ExtractableTranslationList *etl = _extractable_translations;
|
ExtractableTranslationList *etl = _extractable_translations;
|
||||||
List<StringName> msgids;
|
List<StringName> msgids;
|
||||||
while (etl->data) {
|
while (etl->data) {
|
||||||
|
if (!strcmp(etl->lang, "source")) {
|
||||||
Vector<uint8_t> data;
|
Vector<uint8_t> data;
|
||||||
data.resize(etl->uncomp_size);
|
data.resize(etl->uncomp_size);
|
||||||
int ret = Compression::decompress(data.ptrw(), etl->uncomp_size, etl->data, etl->comp_size, Compression::MODE_DEFLATE);
|
int ret = Compression::decompress(data.ptrw(), etl->uncomp_size, etl->data, etl->comp_size, Compression::MODE_DEFLATE);
|
||||||
@@ -175,6 +176,7 @@ List<StringName> get_extractable_message_list() {
|
|||||||
tr->get_message_list(&msgids);
|
tr->get_message_list(&msgids);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
etl++;
|
etl++;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user