I18n: Add message extraction regexes for node socket declarations
The node socket declarations use the `N_()` macro to extract the name and description of the socket. This is quite redundant because since the syntax is always the same, the extraction can be done automatically from the Python translation module using regexes. Four new regexes are introduced in bl_i18n_utils.settings: - one extracts contextless messages from `add_input()` and `add_output()`, the basic socket declarations with the names; - one does the same, but for those sockets which declare a context through `.translation_context()`; - one extracts descriptions and error messages; - one extracts geometry nodes field inputs. In addition to making the code simpler and more legible, this change extracts a few dozen messages which were not tagged with the proper macro.
This commit is contained in:
committed by
Bastien Montagne
parent
f0701bdf73
commit
6d39ba7b41
@@ -256,6 +256,21 @@ PYGETTEXT_KEYWORDS = (() +
|
||||
tuple(("{}\\((?:[^,]+,){{2}}\\s*" + _msg_re + r"\s*(?:\)|,)").format(it)
|
||||
for it in ("modifier_subpanel_register", "gpencil_modifier_subpanel_register")) +
|
||||
|
||||
# Node socket declarations: contextless names
|
||||
tuple((r"\.{}<decl::.*?>\(\s*" + _msg_re + r"(?:,[^),]+)*\s*\)").format(it)
|
||||
for it in ("add_input", "add_output")) +
|
||||
|
||||
# Node socket declarations: names with contexts
|
||||
tuple((r"\.{}<decl::.*?>\(\s*" + _msg_re + r"[^;]*\.translation_context\(\s*" + _ctxt_re + r"\s*\)").format(it)
|
||||
for it in ("add_input", "add_output")) +
|
||||
|
||||
# Node socket declarations: description and error messages
|
||||
tuple((r"\.{}\(\s*" + _msg_re + r"\s*\)").format(it)
|
||||
for it in ("description", "error_message_add")) +
|
||||
|
||||
# Geometry Nodes field inputs
|
||||
((r"FieldInput\(CPPType::get<.*?>\(\),\s*" + _msg_re + r"\s*\)"),) +
|
||||
|
||||
# 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
|
||||
|
||||
Reference in New Issue
Block a user