diff options
author | Bastien Montagne <bastien@blender.org> | 2022-08-09 13:22:30 +0300 |
---|---|---|
committer | Campbell Barton <campbell@blender.org> | 2022-08-09 14:07:32 +0300 |
commit | 2de1b06287023000850cfd969584fe0927327c5b (patch) | |
tree | 52fc4b22fbd2b3303984dda0af97488b2d2fff44 /release/scripts/modules | |
parent | efc1d4bb9aa3c2b55867d624670a125b9163cad8 (diff) |
I18n: add extraction of modal event names.
Alternative fix to the one proposed in D15607.
Reviewed By: campbellbarton
Differential Revision: https://developer.blender.org/D15643
Diffstat (limited to 'release/scripts/modules')
-rw-r--r-- | release/scripts/modules/bl_i18n_utils/bl_extract_messages.py | 15 |
1 files changed, 14 insertions, 1 deletions
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 e4845215ff3..a44b3ac132b 100644 --- a/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py +++ b/release/scripts/modules/bl_i18n_utils/bl_extract_messages.py @@ -359,12 +359,25 @@ def dump_rna_messages(msgs, reports, settings, verbose=False): walk_properties(cls) + def walk_keymap_modal_events(keyconfigs, keymap_name, msgsrc_prev, km_i18n_context): + for keyconfig in keyconfigs: + keymap = keyconfig.keymaps.get(keymap_name, None) + if keymap and keymap.is_modal: + for modal_event in keymap.modal_event_values: + msgsrc = msgsrc_prev + ":'{}'".format(modal_event.identifier) + if modal_event.name: + process_msg(msgs, km_i18n_context, modal_event.name, msgsrc, reports, None, settings) + if modal_event.description: + process_msg(msgs, default_context, modal_event.description, msgsrc, reports, None, settings) + def walk_keymap_hierarchy(hier, msgsrc_prev): km_i18n_context = bpy.app.translations.contexts.id_windowmanager for lvl in hier: msgsrc = msgsrc_prev + "." + lvl[1] if isinstance(lvl[0], str): # Can be a function too, now, with tool system... - process_msg(msgs, km_i18n_context, lvl[0], msgsrc, reports, None, settings) + keymap_name = lvl[0] + process_msg(msgs, km_i18n_context, keymap_name, msgsrc, reports, None, settings) + walk_keymap_modal_events(bpy.data.window_managers[0].keyconfigs, keymap_name, msgsrc, km_i18n_context) if lvl[3]: walk_keymap_hierarchy(lvl[3], msgsrc) |