diff options
author | Bastien Montagne <bastien@blender.org> | 2022-08-09 13:22:30 +0300 |
---|---|---|
committer | Bastien Montagne <bastien@blender.org> | 2022-08-09 13:22:30 +0300 |
commit | 630b961f234e4b1b9839a7d427d68d3f028e528f (patch) | |
tree | 3702816bcc48c34e5ec49febe332cc3f04c41c0c /release/scripts/modules | |
parent | 2682a59efe53a719266da4175633789ef195c8d4 (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) |