I18n: fixes to add-on message extraction
This commit fixes several issues in add-ons UI messages extraction code: - In multi-file modules, the script would crash because it tried to write to the dir instead of a `translations.py` file; - The add-on message extraction works by enabling the add-on, getting all messages; disabling the add-on, getting all messages; then comparing the two message sets. But often a bug happens where a class gets a description from somewhere else in memory. I couldn’t debug that, so a workaround is to check that the message isn’t a corrupted one before removing it; - `printf()` doesn't exist in Python and would crash the script; - `self.src[self.settings.PARSER_PY_ID]` can be replaced by `self.py_file` in class `I18n`, since a property exists to do that; - At one point a generator was printed instead of its values, so let's unpack the generator to get the values. Maybe the print could be deleted entirely; - Use SPDX license identifier instead of GPL license block, to be more in line with other scripts from the codebase. Reviewed By: mont29 Differential Revision: https://developer.blender.org/D15474
This commit is contained in:
@@ -962,7 +962,12 @@ def dump_addon_messages(module_name, do_checks, settings):
|
||||
# and make the diff!
|
||||
for key in minus_msgs:
|
||||
if key != settings.PO_HEADER_KEY:
|
||||
del msgs[key]
|
||||
if key in msgs:
|
||||
del msgs[key]
|
||||
else:
|
||||
# This should not happen, but some messages seem to have
|
||||
# leaked on add-on unregister and register?
|
||||
print(f"Key not found in msgs: {key}")
|
||||
|
||||
if check_ctxt:
|
||||
_diff_check_ctxt(check_ctxt, minus_check_ctxt)
|
||||
|
||||
Reference in New Issue
Block a user