From 79c178b0156045a54974dea10b7cf59426c8762c Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 31 Mar 2019 18:43:14 +0200 Subject: 18N for tools definitions: make them resilient to None context. Dynamic callbacks generating lists of tools should accept None context, not crash on it. Similar to what we do with dynamic RNA enums, when NULL/None context is given, assume we are in 'introspection' mode and return as many things as possible. This is currently essentially used by i18n messages extraction tool (where getting all possible entries is kind of mandatory ;) ). Also add some initial missing tranlations for complex cases that cannot be automated, there'll likely be more of that kind... --- .../scripts/startup/bl_ui/space_toolsystem_toolbar.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'release/scripts') diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py index 90a25182437..42953a05ca6 100644 --- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py +++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py @@ -32,6 +32,12 @@ from .space_toolsystem_common import ( ToolDef, ) +from bpy.app.translations import pgettext_iface as iface_ +from bpy.app.translations import pgettext_tip as tip_ + + +I18N_CTX_OPERATOR = bpy.app.translations.contexts_C_to_py['BLT_I18NCONTEXT_OPERATOR_DEFAULT'] + def kmi_to_string_or_none(kmi): return kmi.to_string() if kmi else "" @@ -116,12 +122,14 @@ class _defs_view3d_generic: kmi_add = None kmi_remove = None return ( + tip_( "Measure distance and angles.\n" "\u2022 {} anywhere for new measurement.\n" "\u2022 Drag ruler segment to measure an angle.\n" "\u2022 {} to remove the active ruler.\n" "\u2022 Ctrl while dragging to snap.\n" "\u2022 Shift while dragging to measure surface thickness." + ) ).format( kmi_to_string_or_none(kmi_add), kmi_to_string_or_none(kmi_remove), @@ -973,6 +981,8 @@ class _defs_vertex_paint: @staticmethod def poll_select_mask(context): + if context is None: + return True ob = context.active_object return (ob.type == 'MESH' and (ob.data.use_paint_mask or @@ -993,6 +1003,8 @@ class _defs_texture_paint: @staticmethod def poll_select_mask(context): + if context is None: + return True ob = context.active_object return (ob.type == 'MESH' and (ob.data.use_paint_mask)) @@ -1012,6 +1024,8 @@ class _defs_weight_paint: @staticmethod def poll_select_mask(context): + if context is None: + return True ob = context.active_object return (ob.type == 'MESH' and (ob.data.use_paint_mask or @@ -1072,6 +1086,8 @@ class _defs_image_generic: @staticmethod def poll_uvedit(context): + if context is None: + return True ob = context.edit_object if ob is not None: data = ob.data @@ -1870,7 +1886,7 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel): None, lambda context: ( (_defs_view3d_generic.cursor,) - if context.pose_object + if context is None or context.pose_object else () ), None, -- cgit v1.2.3