I18n: fix node socket extraction regexes

The node socket extraction regexes introduced in 6d39ba7b41 suffered
from two issues:

1. the contextless name extraction would also extract socket names
   which did have a context. To solve, this, use a negative lookahead
   at the end of the regex, containing ".translation_context(".
2. the number of characters in a message was limited to 1, because the
   _str_base component would match one or more chars after the first
   one, while it should have matched zero or more.

This last issues existed before, and the fix allows the extraction of
three new messages.

Pull Request: blender/blender#108052
This commit is contained in:
2023-05-18 17:44:54 +02:00
committed by Gitea
parent b7a71d65f8
commit e718f29ec3

View File

@@ -206,7 +206,7 @@ _str_base = (
r"(?:(?!<\\)(?:\\\\)*\\(?=(?P={_}2)))|"
# The most common case.
".(?!(?P={_}2))"
")+.)" # Don't forget the last char!
")*.)" # Don't forget the last char!
"(?P={_}2)" # And closing quote.
)
str_clean_re = _str_base.format(_="g", capt="P<clean>")
@@ -257,7 +257,8 @@ PYGETTEXT_KEYWORDS = (() +
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)
tuple((r"\.{}<decl::.*?>\(\s*" + _msg_re + r"(?:,[^),]+)*\s*\)"
r"(?![^;]*\.translation_context\()").format(it)
for it in ("add_input", "add_output")) +
# Node socket declarations: names with contexts