mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
monkey patch blender's dump_addon_messages
The way blender gather messages to translate is: 1) disable the addon 2) parse all available strings 3) enable the addon 4) parse all strings available strings again and subtract the ones gathered at step 2. But due Blender bug (https://projects.blender.org/blender/blender/issues/116579) not all addon parts unregistered at step 1, so some addon's strings left out and gathered at step 2 and then subtracted at step 4. At the end, we loose them and they will be missing from resulting translations files. I've monkey patched dump_addon_messages so it now works a bit more safe: 0) It expects addon to be disabled and Blender restarted after 1) Gather all Blender strings 2) Enable addon 3) Gather all Blender strings again and subtract strings from step 1.
This commit is contained in:
@@ -138,14 +138,8 @@ def dump_addon_messages(module_name, do_checks, settings):
|
||||
print_info,
|
||||
)
|
||||
|
||||
# Get current addon state (loaded or not):
|
||||
was_loaded = addon_utils.check(module_name)[1]
|
||||
|
||||
# Enable our addon.
|
||||
addon = utils.enable_addons(addons={module_name})[0]
|
||||
|
||||
addon_info = addon_utils.module_bl_info(addon)
|
||||
ver = addon_info["name"] + " " + ".".join(str(v) for v in addon_info["version"])
|
||||
ver = module_name
|
||||
rev = 0
|
||||
date = datetime.datetime.now()
|
||||
pot = utils.I18nMessages.gen_empty_messages(
|
||||
@@ -161,24 +155,20 @@ def dump_addon_messages(module_name, do_checks, settings):
|
||||
check_ctxt = _gen_check_ctxt(settings) if do_checks else None
|
||||
minus_check_ctxt = _gen_check_ctxt(settings) if do_checks else None
|
||||
|
||||
# Get strings from RNA, our addon being enabled.
|
||||
print("A")
|
||||
reports = _gen_reports(check_ctxt)
|
||||
print("B")
|
||||
dump_rna_messages(msgs, reports, settings)
|
||||
print("C")
|
||||
|
||||
# Now disable our addon, and re-scan RNA.
|
||||
utils.enable_addons(addons={module_name}, disable=True)
|
||||
# Get strings from RNA, our addon being disabled
|
||||
print("D")
|
||||
reports["check_ctxt"] = minus_check_ctxt
|
||||
reports = _gen_reports(check_ctxt)
|
||||
print("E")
|
||||
dump_rna_messages(minus_msgs, reports, settings)
|
||||
print("F")
|
||||
|
||||
# Restore previous state if needed!
|
||||
if was_loaded:
|
||||
utils.enable_addons(addons={module_name})
|
||||
# Now enable our addon, and re-scan RNA.
|
||||
addon = utils.enable_addons(addons={module_name})[0]
|
||||
print("A")
|
||||
reports["check_ctxt"] = minus_check_ctxt
|
||||
print("B")
|
||||
dump_rna_messages(msgs, reports, settings)
|
||||
print("C")
|
||||
|
||||
# and make the diff!
|
||||
for key in minus_msgs:
|
||||
|
||||
Reference in New Issue
Block a user