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
This commit is contained in:
Bastien Montagne 2022-08-09 12:22:30 +02:00
parent 2682a59efe
commit 630b961f23
Notes: blender-bot 2023-02-14 02:58:19 +01:00
Referenced by commit 8a205b4036, Fix status bar keymap items during modal operations
1 changed files with 14 additions and 1 deletions

View File

@ -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)