From a4869df4c9d27279b44171d12cdece8989aaf255 Mon Sep 17 00:00:00 2001 From: Bastien Montagne Date: Sun, 31 Mar 2019 18:49:11 +0200 Subject: I18n messages extraction: add 'generic' handling of Tools. --- .../modules/bl_i18n_utils/bl_extract_messages.py | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'release/scripts') 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 d552638850c..9ea19da2160 100644 --- a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py +++ b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py @@ -351,6 +351,35 @@ def dump_rna_messages(msgs, reports, settings, verbose=False): process_msg(msgs, default_context, item.description, msgsrc, reports, check_ctxt_rna_tip, settings) + def walk_tools_definitions(cls): + from bl_ui.space_toolsystem_common import ToolDef + + bl_rna = cls.bl_rna + op_default_context = bpy.app.translations.contexts.operator_default + + def process_tooldef(tool_context, tool): + if not isinstance(tool, ToolDef): + if callable(tool): + for t in tool(None): + process_tooldef(tool_context, t) + return + msgsrc = "bpy.types.{} Tools: '{}', '{}'".format(bl_rna.identifier, tool_context, tool.idname) + if tool.label: + process_msg(msgs, op_default_context, tool.label, msgsrc, reports, check_ctxt_rna, settings) + # Callable (function) descriptions must handle their translations themselves. + if tool.description and not callable(tool.description): + process_msg(msgs, default_context, tool.description, msgsrc, reports, check_ctxt_rna_tip, settings) + + for tool_context, tools_defs in cls.tools_all(): + for tools_group in tools_defs: + if tools_group is None: + continue + elif isinstance(tools_group, tuple) and not isinstance(tools_group, ToolDef): + for tool in tools_group: + process_tooldef(tool_context, tool) + else: + process_tooldef(tool_context, tools_group) + blacklist_rna_class = class_blacklist() def walk_class(cls): @@ -373,6 +402,10 @@ def dump_rna_messages(msgs, reports, settings, verbose=False): if hasattr(bl_rna, 'bl_label') and bl_rna.bl_label: process_msg(msgs, msgctxt, bl_rna.bl_label, msgsrc, reports, check_ctxt_rna, settings) + # Tools Panels definitions. + if hasattr(bl_rna, 'tools_all') and bl_rna.tools_all: + walk_tools_definitions(cls) + walk_properties(cls) def walk_keymap_hierarchy(hier, msgsrc_prev): -- cgit v1.2.3