WIP: I18n: make favorites menu entry names translations depend on language #112327

Draft
Damien Picard wants to merge 2 commits from pioverfour/blender:dp_fix_110368 into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Member

Buttons can be added to the quick favorites menu. The name of this
button is stored in a menu entry structure. Depending on the button
type (property, menu, operator), the name will be obtained in
different ways.

The correct name to store to is the untranslated one, because we want
to translate only when the menu is called. But in the case of
operators, the name copied to the struct was translated. This caused
the quick favorites menu to ignore language change and always display
the name as it was translated at the time of addition.

This commit adds a new function to get the raw, untranslated operator
name instead.

Fixes #110368: Favorites menu does not take into account language change

TODO

  • operators
  • operators with arguments (e.g. add a specific modifier),
  • menus
  • ...?
Buttons can be added to the quick favorites menu. The name of this button is stored in a menu entry structure. Depending on the button type (property, menu, operator), the name will be obtained in different ways. The correct name to store to is the untranslated one, because we want to translate only when the menu is called. But in the case of operators, the name copied to the struct was translated. This caused the quick favorites menu to ignore language change and always display the name as it was translated at the time of addition. This commit adds a new function to get the raw, untranslated operator name instead. Fixes #110368: Favorites menu does not take into account language change **TODO** - [ ] operators - [ ] operators with arguments (e.g. add a specific modifier), - [ ] menus - [ ] ...?
Damien Picard added the
Interest
Translations
label 2023-09-13 14:37:45 +02:00
Damien Picard added 1 commit 2023-09-13 14:37:57 +02:00
Buttons can be added to the quick favorites menu. The name of this
button is stored in a menu entry structure. Depending on the button
type (property, menu, operator), the name will be obtained in
different ways.

The correct name to store to is the untranslated one, because we want
to translate only when the menu is called. But in the case of
operators, the name copied to the struct was translated. This caused
the quick favorites menu to ignore language change and always display
the name as it was translated at the time of addition.

This commit adds a new function to get the raw, untranslated operator
name instead.

Fixes #110368: Favorites menu does not take into account language change

TODO
- menus
- operators with attributes (e.g. add specific mod),
- ...?
Hans Goudey reviewed 2023-09-13 19:28:35 +02:00
@ -586,0 +591,4 @@
name = ot->get_name(ot, properties);
}
return name.empty() ? std::string(RNA_struct_ui_name_raw(ot->srna)) : name;
Member

It might be nice to implement WM_operatortype_name in terms of WM_operatortype_name_raw, just like this:

return IFACE_(WM_operatortype_name_raw(ot, properties));

It might be nice to implement `WM_operatortype_name` in terms of `WM_operatortype_name_raw`, just like this: `return IFACE_(WM_operatortype_name_raw(ot, properties));`
Author
Member

I tried doing that but actually it’s a bit more complex. A few operators get their name from a get_name callback which is supposed to return a translated name. 203e6e2b41 for instance changed things in that direction.

This means that if there is such a callback, WM_operatortype_name shouldn’t do any translation. It also means that currently, some operators cannot get an untranslated name at all. I’m not sure it’s worth it making get_name not translate right now as only a dozen operators use this, but still WM_operatortype_name should handle those cases.

I tried doing that but actually it’s a bit more complex. A few operators get their name from a `get_name` callback which is supposed to return a translated name. 203e6e2b41 for instance changed things in that direction. This means that if there is such a callback, `WM_operatortype_name` shouldn’t do any translation. It also means that currently, some operators cannot get an untranslated name at all. I’m not sure it’s worth it making `get_name` not translate right now as only a dozen operators use this, but still `WM_operatortype_name` should handle those cases.
Damien Picard added 1 commit 2023-09-27 21:11:38 +02:00
Author
Member

I’m stuck with this because the translation is often based on uiButs’ drawstr, which is already translated. In order to get the untranslated string, it should be stored in the uiBut as well, but this feels redundant.

The alternative would be to store only the untranslated string, but I couldn’t find where this drawstr is updated from, as I assume it is when the user changes the UI language.

I’m stuck with this because [the translation is often based on](https://projects.blender.org/blender/blender/src/branch/main/source/blender/editors/interface/interface_context_menu.cc#L362) `uiBut`s’ `drawstr`, which is already translated. In order to get the untranslated string, it should be stored in the `uiBut` as well, but this feels redundant. The alternative would be to store only the untranslated string, but I couldn’t find where this `drawstr` is updated from, as I assume it is when the user changes the UI language.
This pull request is marked as a work in progress.
This branch is out-of-date with the base branch

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u dp_fix_110368:pioverfour-dp_fix_110368
git checkout pioverfour-dp_fix_110368
Sign in to join this conversation.
No reviewers
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#112327
No description provided.