diff options
author | Bastien Montagne <montagne29@wanadoo.fr> | 2017-06-28 21:50:21 +0300 |
---|---|---|
committer | Bastien Montagne <montagne29@wanadoo.fr> | 2017-06-28 21:50:21 +0300 |
commit | b5696f27991ce8ff9c95ed54d0a0387ed31f02ce (patch) | |
tree | 17ca4dcd9bccfd0ebb4d11b207688eb699ee3ecd /release | |
parent | 16eca8f47ed6096ce726306b1059f4d50b04454f (diff) |
Fix node UI not using translation context correctly.
Now that some node types may have custom context, we need to handle that
in the (convoluted :| ) UI code of nodes as well.
Reported in T43295 by Gabriel Gazzán (@gab3d), thanks.
Diffstat (limited to 'release')
-rw-r--r-- | release/scripts/modules/nodeitems_utils.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/release/scripts/modules/nodeitems_utils.py b/release/scripts/modules/nodeitems_utils.py index be6f031217c..904062c36cd 100644 --- a/release/scripts/modules/nodeitems_utils.py +++ b/release/scripts/modules/nodeitems_utils.py @@ -61,13 +61,19 @@ class NodeItem: # if no custom label is defined, fall back to the node type UI name return getattr(bpy.types, self.nodetype).bl_rna.name + @property + def translation_context(self): + if self._label: + return bpy.app.translations.contexts.default + else: + # if no custom label is defined, fall back to the node type UI name + return getattr(bpy.types, self.nodetype).bl_rna.translation_context + # NB: is a staticmethod because called with an explicit self argument # NodeItemCustom sets this as a variable attribute in __init__ @staticmethod def draw(self, layout, context): - default_context = bpy.app.translations.contexts.default - - props = layout.operator("node.add_node", text=self.label, text_ctxt=default_context) + props = layout.operator("node.add_node", text=self.label, text_ctxt=self.translation_context) props.type = self.nodetype props.use_transform = True |