From e718f29ec37dda315a00e6a8625be2f4ad9801ac Mon Sep 17 00:00:00 2001 From: Damien Picard Date: Thu, 18 May 2023 17:44:54 +0200 Subject: [PATCH] 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: https://projects.blender.org/blender/blender/pulls/108052 --- scripts/modules/bl_i18n_utils/settings.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/scripts/modules/bl_i18n_utils/settings.py b/scripts/modules/bl_i18n_utils/settings.py index f9a3ffe384a..2733c2e7fbd 100644 --- a/scripts/modules/bl_i18n_utils/settings.py +++ b/scripts/modules/bl_i18n_utils/settings.py @@ -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") @@ -257,7 +257,8 @@ PYGETTEXT_KEYWORDS = (() + for it in ("modifier_subpanel_register", "gpencil_modifier_subpanel_register")) + # Node socket declarations: contextless names - tuple((r"\.{}\(\s*" + _msg_re + r"(?:,[^),]+)*\s*\)").format(it) + tuple((r"\.{}\(\s*" + _msg_re + r"(?:,[^),]+)*\s*\)" + r"(?![^;]*\.translation_context\()").format(it) for it in ("add_input", "add_output")) + # Node socket declarations: names with contexts