Page MenuHome

I18n: make more parts of the UI translatable
ClosedPublic

Authored by Damien Picard (pioverfour) on Aug 2 2022, 10:35 PM.

Details

Summary
  • "Name collisions" label in mesh properties
  • "Threshold" labels in Vertex Weight Edit modifier
  • "Particle System" label in Particle Instance modifier
  • Slot number in the Shader Editor
  • Status bar keymap items during modal operations: add TIP_() macro to status bar interface template
  • On dumping messages, sort preset files so their messages are stable between runs

Ref. T43295

Diff Detail

Repository
rB Blender

Event Timeline

Damien Picard (pioverfour) requested review of this revision.Aug 2 2022, 10:35 PM
Damien Picard (pioverfour) created this revision.

Do not translate event_text in status bar.

Bastien Montagne (mont29) requested changes to this revision.Aug 4 2022, 3:38 PM
Bastien Montagne (mont29) added inline comments.
release/scripts/modules/bl_i18n_utils/settings.py
259–262 ↗(On Diff #54329)

I don't think you need this to get modal keymaps accessible. They should already been extracted, but they are using the bpy.app.translations.contexts.id_windowmanager context. Isn't your issue that you use TIP_( and not CTX_TIP_(BLT_I18NCONTEXT_ID_WINDOWMANAGER, to translate them in the UI in your change below?

release/scripts/startup/bl_ui/properties_data_mesh.py
597

should be tip_ here, same rational as usual (this is not actually a label, but actual more complex/detailed info for the user).

This revision now requires changes to proceed.Aug 4 2022, 3:38 PM
release/scripts/modules/bl_i18n_utils/settings.py
259–262 ↗(On Diff #54329)

Then maybe modal keymap is not the proper term, but I’m sure many messages aren’t extracted. What I’m referring to is this, which appears during transform:

Here, the messages that do get translated with my change (e.g. “Déplacer”) were extracted from entirely different sources. “Snap Invert” is not in the .po files under any context. It comes from editors/transform/transform.c and looks like this, which I don’t think is handled currently:

{TFM_MODAL_SNAP_INV_ON, "SNAP_INV_ON", 0, "Snap Invert", ""},

So I believe the regex is still useful, but now you mention it, maybe it should get a context, and then the TIP_() change below is wrong. However I couldn’t yet find out how to use regexps to extract messages from the source with a context, if it’s not explicitly specified there, as the macros do. I’ll keep trying.

release/scripts/startup/bl_ui/properties_data_mesh.py
597

Damn, my bad!

release/scripts/modules/bl_i18n_utils/settings.py
259–262 ↗(On Diff #54329)

Ok so I found a way to override the context in the regex but it involves changing PYGETTEXT_KEYWORDS from a tuple of patterns to a tuple of (pattern, context) tuples, with context potentially None. So you get:

PYGETTEXT_KEYWORDS = (() +
    tuple(((r"<pattern>" + _msg_re + r"<pattern>").format(it),
           None)
          for it in ("IFACE_", "TIP_", "DATA_", "N_")) +

...

    tuple(((r"<pattern>" + _msg_re + r"<pattern>").format(it),
           bpy.app.translations.contexts.id_windowmanager)
          for it in ("_MODAL_",)) +

Not sure it’s either truly needed or the best way to proceed.

@Damien Picard (pioverfour) OK I see the issue now, but extracting such strings this way is really not the best option... Created an alternative fix in D15643, which exposes possible event enum items for each modal keymap in RNA directly.

Damien Picard (pioverfour) edited the summary of this revision. (Show Details)

Remove changes related to modal keymaps—to be handled in D15643

@Damien Picard (pioverfour) OK I see the issue now, but extracting such strings this way is really not the best option... Created an alternative fix in D15643, which exposes possible event enum items for each modal keymap in RNA directly.

That’s great, thanks! It makes a lot more sense…

Damien Picard (pioverfour) marked an inline comment as done.
Damien Picard (pioverfour) edited the summary of this revision. (Show Details)

Actually removed too much, only meant to remove the regex.

This revision is now accepted and ready to land.Aug 9 2022, 12:41 PM