I18n: Add suport for labels from modifiers' subpanels.

Was a bit oif a struggle since those functions take a first string which
is not our label, but should work fine now.

Reported/detected as part of D15418.
This commit is contained in:
Bastien Montagne 2022-07-15 11:41:13 +02:00
parent 8e1323f633
commit e69c4482f1
2 changed files with 17 additions and 11 deletions

View File

@ -803,20 +803,21 @@ def dump_src_messages(msgs, reports, settings):
line += data[pos:m.start()].count('\n')
msgsrc = rel_path + ":" + str(line)
_msgid = d.get("msg_raw")
# First, try the "multi-contexts" stuff!
_msgctxts = tuple(d.get("ctxt_raw{}".format(i)) for i in range(settings.PYGETTEXT_MAX_MULTI_CTXT))
if _msgctxts[0]:
for _msgctxt in _msgctxts:
if not _msgctxt:
break
if _msgid not in {'""', "''"}:
# First, try the "multi-contexts" stuff!
_msgctxts = tuple(d.get("ctxt_raw{}".format(i)) for i in range(settings.PYGETTEXT_MAX_MULTI_CTXT))
if _msgctxts[0]:
for _msgctxt in _msgctxts:
if not _msgctxt:
break
msgctxt, msgid = process_entry(_msgctxt, _msgid)
process_msg(msgs, msgctxt, msgid, msgsrc, reports, check_ctxt_src, settings)
reports["src_messages"].append((msgctxt, msgid, msgsrc))
else:
_msgctxt = d.get("ctxt_raw")
msgctxt, msgid = process_entry(_msgctxt, _msgid)
process_msg(msgs, msgctxt, msgid, msgsrc, reports, check_ctxt_src, settings)
reports["src_messages"].append((msgctxt, msgid, msgsrc))
else:
_msgctxt = d.get("ctxt_raw")
msgctxt, msgid = process_entry(_msgctxt, _msgid)
process_msg(msgs, msgctxt, msgid, msgsrc, reports, check_ctxt_src, settings)
reports["src_messages"].append((msgctxt, msgid, msgsrc))
pos = m.end()
line += data[m.start():pos].count('\n')

View File

@ -251,6 +251,11 @@ PYGETTEXT_KEYWORDS = (() +
tuple(("{}\\((?:[^\"',]+,){{2}}\\s*" + _msg_re + r"\s*(?:\)|,)").format(it)
for it in ("BKE_modifier_set_error",)) +
# This one is a tad more risky, but in practice would not expect a name/uid string parameter
# (the second one in those functions) to ever have a comma in it, so think this is fine.
tuple(("{}\\((?:[^,]+,){{2}}\\s*" + _msg_re + r"\s*(?:\)|,)").format(it)
for it in ("modifier_subpanel_register", "gpencil_modifier_subpanel_register")) +
# bUnitDef unit names.
# NOTE: regex is a bit more complex than it would need too. Since the actual
# identifier (`B_UNIT_DEF_`) is at the end, if it's simpler/too general it