WIP: I18n: add per-label translation contexts for nodes #105690
Draft
Damien Picard
wants to merge 3 commits from
When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
pioverfour/blender:dp_add_i18n_context_socket_label
into blender-v3.6-release
pull from: pioverfour/blender:dp_add_i18n_context_socket_label
merge into: blender:blender-v3.6-release
blender:main
blender:blender-v4.0-release
blender:temp-sculpt-dyntopo
blender:temp-sculpt-brush-channel
blender:blender-v3.6-release
blender:universal-scene-description
blender:blender-v3.3-release
blender:asset-browser-frontend-split
blender:brush-assets-project
blender:asset-shelf
blender:anim/armature-drawing-refactor-3
blender:temp-sculpt-dyntopo-hive-alloc
blender:tmp-usd-python-mtl
blender:tmp-usd-3.6
blender:blender-v3.5-release
blender:blender-projects-basics
blender:blender-v2.93-release
blender:temp-sculpt-attr-api
blender:realtime-clock
blender:sculpt-dev
blender:gpencil-next
blender:bevelv2
blender:microfacet_hair
blender:xr-dev
blender:principled-v2
When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
Reviewers
Request review
No reviewers
Labels
Clear labels
This issue affects/is about backward or forward compatibility
Issues relating to security: https://wiki.blender.org/wiki/Process/Vulnerability_Reports
Apply labels
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
This issue affects/is about backward or forward 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
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
Issues relating to security: https://wiki.blender.org/wiki/Process/Vulnerability_Reports
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 Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
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
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
Milestone
Set milestone
Clear milestone
No items
No Milestone
Projects
Set Project
Clear projects
No project
Assignees
Assign users
Clear assignees
No Assignees
4 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#105690
Reference in New Issue
There is no content yet.
Delete Branch "pioverfour/blender:dp_add_i18n_context_socket_label"
Deleting a branch is permanent. Although the deleted branch may exist for a short time before cleaning up, in most cases it CANNOT be undone. Continue?
In order to properly translate UI messages, they sometimes need to be
disambiguated using translation contexts. Until now, node sockets
using custom labels had no way to specify contexts and a collision
occurred in at least one known instance.
This commit adds a way to declare contexts for each socket with
labels, by adding a
label_translation_context
field to thebNodeSocket struct, as well as a
translation_context
argument to thenode_sock_label()
function.If no context is specified, the default null context is used.
The use of a context enables us to fix part of #105113.
This PR contains three commits:
Not sure about defining i18n contexts at such a fine grained level tbh, wouldn't it make more sense to add an optional i18n context to the NodeType, and when defined, use it for all of its UI strings?
I realize this is actually in the continuity of !105195 now... But still, feels a bit odd/over-specific to me.
To me, too, but then again I find the use of labels a bit odd and overly specific in the first place.
When I first tried adding contexts to sockets in D15869, @HooglyBoogly explained that “[he]'d like to avoid storing the context per socket”. This is once more what I’m doing and I do think it’s not ideal, but the labels are a different system from ordinary socket names: they are not declared at the node level. So I’m not sure how to do it better..
Another bad issue fixable with this PR was reported at #43295.
cb716fd007
to1b31dd9a28
1b31dd9a28
toe566a26026
@ -31,3 +31,3 @@
/**** Updates ****/
void node_sock_label(bNodeSocket *sock, const char *name);
void node_sock_label(bNodeSocket *sock, const char *name, const char *translation_context = "\0");
Would rather have default value be
BLT_I18NCONTEXT_DEFAULT
(akanullptr
). Also meansnode_sock_label
code changes need an update.97a79c8e11
tod57e8c278a
Is it too late to rebase this on 3.6?
@pioverfour no think these kind of changes are fine still for 3.6 ;)
d57e8c278a
to11ce69e58f
Cool, thanks! I’ve rebased.
@ -142,6 +142,7 @@ typedef struct bNodeSocket {
/** Custom dynamic defined label, MAX_NAME. */
char label[64];
char description[64];
char label_translation_context[64];
Adding 64 byte to every socket for this is not really acceptable. Better move this to run-time data if possible (
bNodeSocketRuntime
).Thanks, it makes a lot more sense!
In run-time data you can also use e.g.
std::string
which in this case would also be smaller usually.d7c1753f30
to29830181ca
I strongly disagree with the suggested change (moving translation context into runtime data).
Translation context should not be split away from the string it affects, either all UI strings move into runtime, or everything stays into DNA struct.
I can try to move the label and description into runtime data then. Would that be all right?
On a conceptual level, I really think this should be stored in the socket declaration, not the socket. The declaration describes all sockets in all nodes. Storing the same data for every socket instance just shouldn't be necessary, whether it's in runtime data or DNA.
The node Python API hasn't really caught up to this design with declarations yet, but exposing it the general future plan anyway.
I agree that this data is very redundant, but since the label system was designed in this redundant way I figured it made sense to apply the same logic to translations, at least until a better system was implemented.
I see! I’ll wait a while to see how things evolve before returning to this, then.
I18n: add per-label translation contexts for nodesto WIP: I18n: add per-label translation contexts for nodesMemory usage cost aside, I'd agree, but that aspect means there a real reason to avoid redundancy.
Well, this doesn't need to be exposed to the Python API to be useful. Whether to wait is obviously your call though!
I mean, maybe there’s something I’m missing, but I don’t see how to attach translation contexts to labels using the socket declarations, in the current state of things. The labels are an ad-hoc name override that is never the same as the
name
from the socket declaration.See for instance the Separate Colors node: its third input has "Blue" for its
name
, but itslabel
can be any of "Blue", "Value", "Lightness", "Cr" or "V". So this label must have its own translation context, distinct from that of the name.So unless I’m mistaken, in order for this to work with declarations the label system would need to be redesigned, and I don’t think I can pull that off!
The translation context could be a callback like
make_available
, that wouldn't probably be pretty straightforward. But yeah, understandable to wait.Reviewers