Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBastien Montagne <montagne29@wanadoo.fr>2019-03-31 19:43:14 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2019-03-31 19:47:54 +0300
commit79c178b0156045a54974dea10b7cf59426c8762c (patch)
tree532da3875487b2b12009ac6678d44b3447dbe7fa /release/scripts
parent54943e319ad89c0b4aff6320ecbd955338ea8948 (diff)
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...
Diffstat (limited to 'release/scripts')
-rw-r--r--release/scripts/startup/bl_ui/space_toolsystem_toolbar.py18
1 files changed, 17 insertions, 1 deletions
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 "<none>"
@@ -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,