[Bf-blender-cvs] [fe8b197] master: Fix T49150: make new 'operator categories' in search menu i18n-aware.

Bastien Montagne noreply at git.blender.org
Tue Aug 23 21:49:21 CEST 2016


Commit: fe8b197269fda1b6747c022eb93b2781353008d5
Author: Bastien Montagne
Date:   Tue Aug 23 21:48:16 2016 +0200
Branches: master
https://developer.blender.org/rBfe8b197269fda1b6747c022eb93b2781353008d5

Fix T49150: make new 'operator categories' in search menu i18n-aware.

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

M	release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
M	source/blender/editors/interface/interface_regions.c

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

diff --git a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
index 5a3eda5..dc1ddbf 100644
--- a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
+++ b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py
@@ -375,6 +375,7 @@ def dump_rna_messages(msgs, reports, settings, verbose=False):
                 walk_keymap_hierarchy(lvl[3], msgsrc)
 
     # Dump Messages
+    operator_categories = {}
     def process_cls_list(cls_list):
         if not cls_list:
             return
@@ -391,6 +392,16 @@ def dump_rna_messages(msgs, reports, settings, verbose=False):
                 cls_id = bl_rna.identifier + "." + cls_id
                 bl_rna = bl_rna.base
             return cls_id
+
+        def operator_category(cls):
+            """Extract operators' categories, as displayed in 'search' space menu."""
+            # NOTE: keep in sync with C code in ui_searchbox_region_draw_cb__operator().
+            if issubclass(cls, bpy.types.OperatorProperties) and "_OT_" in cls.__name__:
+                cat_id = cls.__name__.split("_OT_")[0]
+                if cat_id not in operator_categories:
+                    cat_str = cat_id.capitalize() + ":"
+                    operator_categories[cat_id] = cat_str
+
         if verbose:
             print(cls_list)
         cls_list.sort(key=full_class_id)
@@ -402,6 +413,7 @@ def dump_rna_messages(msgs, reports, settings, verbose=False):
             if (cls in blacklist_rna_class) or issubclass(cls, bpy.types.Operator):
                 reports["rna_structs_skipped"].append(cls)
             else:
+                operator_category(cls)
                 walk_class(cls)
             # Recursively process subclasses.
             process_cls_list(cls.__subclasses__())
@@ -409,6 +421,11 @@ def dump_rna_messages(msgs, reports, settings, verbose=False):
     # Parse everything (recursively parsing from bpy_struct "class"...).
     process_cls_list(bpy.types.ID.__base__.__subclasses__())
 
+    # Finalize generated 'operator categories' messages.
+    for cat_str in operator_categories.values():
+        process_msg(msgs, bpy.app.translations.contexts.operator_default, cat_str, "Generated operator category",
+                    reports, check_ctxt_rna, settings)
+
     # And parse keymaps!
     from bpy_extras.keyconfig_utils import KM_HIERARCHY
     walk_keymap_hierarchy(KM_HIERARCHY, "KM_HIERARCHY")
diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c
index c621fcf..c507401 100644
--- a/source/blender/editors/interface/interface_regions.c
+++ b/source/blender/editors/interface/interface_regions.c
@@ -1380,6 +1380,7 @@ static void ui_searchbox_region_draw_cb__operator(const bContext *UNUSED(C), ARe
 			rect_pre.xmax = rect_post.xmin = rect.xmin + ((rect.xmax - rect.xmin) / 4);
 
 			/* widget itself */
+			/* NOTE: i18n messages extracting tool does the same, please keep it in sync. */
 			{
 				wmOperatorType *ot = data->items.pointers[a];
 
@@ -1400,7 +1401,8 @@ static void ui_searchbox_region_draw_cb__operator(const bContext *UNUSED(C), ARe
 				}
 
 				rect_pre.xmax += 4;  /* sneaky, avoid showing ugly margin */
-				ui_draw_menu_item(&data->fstyle, &rect_pre, text_pre, data->items.icons[a], state, false);
+				ui_draw_menu_item(&data->fstyle, &rect_pre, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, text_pre),
+				                  data->items.icons[a], state, false);
 				ui_draw_menu_item(&data->fstyle, &rect_post, data->items.names[a], 0, state, data->use_sep);
 			}




More information about the Bf-blender-cvs mailing list