[Bf-blender-cvs] [535c9308ef1] master: Fix T97429: Translateable Unit Names Missing in the File.

Bastien Montagne noreply at git.blender.org
Fri Apr 22 16:19:10 CEST 2022


Commit: 535c9308ef16c0bf0a5daa54c6bfd72a0dbf6ca3
Author: Bastien Montagne
Date:   Fri Apr 22 15:37:16 2022 +0200
Branches: master
https://developer.blender.org/rB535c9308ef16c0bf0a5daa54c6bfd72a0dbf6ca3

Fix T97429: Translateable Unit Names Missing in the File.

Added some regex magic in i18n py module to also extract UI names from
all of our units definitions.

Those enum values are fully dynamically generated, so they cannot be
extracted from RNA introspection.

===================================================================

M	release/scripts/modules/bl_i18n_utils/settings.py
M	source/blender/makesrna/intern/rna_scene.c

===================================================================

diff --git a/release/scripts/modules/bl_i18n_utils/settings.py b/release/scripts/modules/bl_i18n_utils/settings.py
index 514ff83e001..a398299aa56 100644
--- a/release/scripts/modules/bl_i18n_utils/settings.py
+++ b/release/scripts/modules/bl_i18n_utils/settings.py
@@ -253,6 +253,14 @@ PYGETTEXT_KEYWORDS = (() +
     tuple(("{}\\((?:[^\"',]+,)\\s*" + _msg_re + r"\s*(?:\)|,)").format(it)
           for it in ("BKE_modifier_set_error",)) +
 
+    # 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
+    # becomes extremely slow to process some (unrelated) source files. 
+    ((r"\{(?:(?:\s*\"[^\"',]+\"\s*,)|(?:\s*NULL\s*,)){4}\s*" +
+      _msg_re + r"\s*,(?:(?:\s*\"[^\"',]+\"\s*,)|(?:\s*NULL\s*,))(?:[^,]+,){2}"
+      + "\s*B_UNIT_DEF_[_A-Z]+\s*\}"),) +
+
     tuple((r"{}\(\s*" + _msg_re + r"\s*,\s*(?:" +
            r"\s*,\s*)?(?:".join(_ctxt_re_gen(i) for i in range(PYGETTEXT_MAX_MULTI_CTXT)) + r")?\s*\)").format(it)
           for it in ("BLT_I18N_MSGID_MULTI_CTXT",))
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index afce68057b2..9148b48978d 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2630,7 +2630,7 @@ static const EnumPropertyItem *rna_UnitSettings_itemf_wrapper(const int system,
 
   EnumPropertyItem adaptive = {0};
   adaptive.identifier = "ADAPTIVE";
-  adaptive.name = "Adaptive";
+  adaptive.name = N_("Adaptive");
   adaptive.value = USER_UNIT_ADAPTIVE;
   RNA_enum_item_add(&items, &totitem, &adaptive);



More information about the Bf-blender-cvs mailing list