I18n: Use fmt::format() to replace string concatenation in nodes #107260

Merged
Bastien Montagne merged 1 commits from pioverfour/blender:dp_geo_nodes_tooltips_fmt into blender-v3.6-release 2023-06-06 16:27:56 +02:00
Member

The UI code for nodes uses stringstreams a few times to format
strings. In some cases it is fine, but in others it makes localization
hard or impossible to do properly, as explained in #92758.

This commit replaces some stringstreams with fmt::format(), a
library that is already used in other parts of Blender and was
suggested by Hans Goudey (@hooglyboogly) in
D15996.


It appears that node socket tooltips are translated during evaluation, which does not happen in the main thread. This means that BLT_translate() will not allow translation to happen. For now, I have modified it to return true, but a better solution should be found and I don’t know where to look. This occurs in at least another area of Blender, more details in #108206.

The UI code for nodes uses `stringstream`s a few times to format strings. In some cases it is fine, but in others it makes localization hard or impossible to do properly, as explained in #92758. This commit replaces some `stringstream`s with `fmt::format()`, a library that is already used in other parts of Blender and was suggested by Hans Goudey (@hooglyboogly) in [D15996](https://archive.blender.org/developer/differential/0015/0015996/#inline-138440). ----- It appears that node socket tooltips are translated during evaluation, which does not happen in the main thread. This means that `BLT_translate()` will not allow translation to happen. For now, I have modified it to return true, but a better solution should be found and I don’t know where to look. This occurs in at least another area of Blender, more details in #108206.
Damien Picard changed title from 18n: Use fmt::format() to replace string concatenation in nodes to WIP: 18n: Use fmt::format() to replace string concatenation in nodes 2023-04-23 04:13:47 +02:00
Damien Picard force-pushed dp_geo_nodes_tooltips_fmt from 85be395a81 to 18dff85c0e 2023-04-24 21:21:22 +02:00 Compare
Damien Picard force-pushed dp_geo_nodes_tooltips_fmt from 18dff85c0e to aaec2c7b69 2023-04-25 15:36:53 +02:00 Compare
Damien Picard force-pushed dp_geo_nodes_tooltips_fmt from aaec2c7b69 to bb38e01688 2023-04-29 00:15:13 +02:00 Compare
Damien Picard force-pushed dp_geo_nodes_tooltips_fmt from bb38e01688 to 015f915e62 2023-05-26 21:01:08 +02:00 Compare
pioverfour changed target branch from main to blender-v3.6-release 2023-05-26 21:01:19 +02:00
Damien Picard changed title from WIP: 18n: Use fmt::format() to replace string concatenation in nodes to 18n: Use fmt::format() to replace string concatenation in nodes 2023-05-26 21:01:53 +02:00
Damien Picard requested review from Bastien Montagne 2023-05-26 21:03:16 +02:00
Author
Member

If this is merged into 3.6, a cleanup will likely need be done when merging into main, to remove #define FMT_HEADER_ONLY, after 0d38fa2422.

If this is merged into 3.6, a cleanup will likely need be done when merging into main, to remove `#define FMT_HEADER_ONLY`, after 0d38fa2422.
Bastien Montagne approved these changes 2023-06-05 18:13:43 +02:00

@blender-bot build

@blender-bot build
Damien Picard changed title from 18n: Use fmt::format() to replace string concatenation in nodes to I18n: Use fmt::format() to replace string concatenation in nodes 2023-06-05 21:45:23 +02:00
Bastien Montagne merged commit d95486af95 into blender-v3.6-release 2023-06-06 16:27:56 +02:00
Bastien Montagne deleted branch dp_geo_nodes_tooltips_fmt 2023-06-06 16:27:57 +02:00

This commit comments out threading which wasn't mentioned in the commit log (although I see it's mentioned in the PR).
Now the threading line is left in but commented without any notes for why it's there. In future it please include changes to multi-threaded behavior in the commit log too, and note why commented code is left in.

This commit comments out threading which wasn't mentioned in the commit log (although I see it's mentioned in the PR). Now the threading line is left in but commented without any notes for why it's there. In future it please include changes to multi-threaded behavior in the commit log too, and note why commented code is left in.
Author
Member

In future it please include changes to multi-threaded behavior in the commit log too, and note why commented code is left in.

All right, I understand. If it's too much of an issue right now, this part of the commit can be reverted and tackled separately.

Otherwise I still plan to look into it some more as part of #108206, if only to clean up and comment.

> In future it please include changes to multi-threaded behavior in the commit log too, and note why commented code is left in. All right, I understand. If it's too much of an issue right now, this part of the commit can be reverted and tackled separately. Otherwise I still plan to look into it some more as part of #108206, if only to clean up and comment.

@pioverfour I completely missed this somehow, will revert that part of the change for now indeed.

Afair, boost translation mechanism is not threadsafe at all, which is why it was disabled in any thread but the main one.

@pioverfour I completely missed this somehow, will revert that part of the change for now indeed. Afair, boost translation mechanism is not threadsafe at all, which is why it was disabled in any thread but the main one.

Reverted threading change in 7ceb33e06e.

Reverted threading change in 7ceb33e06e.
Author
Member

Afair, boost translation mechanism is not threadsafe at all, which is why it was disabled in any thread but the main one.

That's what I figured, I wrote about what I found in the other issue. To be honest I was a bit surprised to see this merged! 😅

Do you have suggestions on the best course of action? I can't reproduce the crashes, so I don't know how to determine if the boost issue is still a thing.

> Afair, boost translation mechanism is not threadsafe at all, which is why it was disabled in any thread but the main one. That's what I figured, I wrote about what I found in the other issue. To be honest I was a bit surprised to see this merged! 😅 Do you have suggestions on the best course of action? I can't reproduce the crashes, so I don't know how to determine if the boost issue is still a thing.

@pioverfour tbh I have a hard time understanding why some UI-related string should be handled in a threaded context. Feels like a design issue in the node system...

@pioverfour tbh I have a hard time understanding why some UI-related string should be handled in a threaded context. Feels like a design issue in the node system...

This PR affected on building of internal field names in geometry node evaluator (multithreaded).

This PR affected on building of internal field names in geometry node evaluator (multithreaded).

My problem is once again: why on earth does UI names have to be 'built during nodetree evaluation'? This does not sounds normal to me, at all.

My problem is once again: why on earth does UI names have to be 'built during nodetree evaluation'? This does not sounds normal to me, at all.
Author
Member

In D15996, @HooglyBoogly wrote:

The fact that we translate these strings during evaluation is bad actually, it would be good to avoid that. They should only be translated when we display them in the UI.

To do that we would need a better way to make inspection strings for fields, but that should be doable.

… so I guess this can be considered a known issue.

In [D15996](https://archive.blender.org/developer/differential/0015/0015996/#437415), @HooglyBoogly wrote: > The fact that we translate these strings during evaluation is bad actually, it would be good to avoid that. They should only be translated when we display them in the UI. > To do that we would need a better way to make inspection strings for fields, but that should be doable. … so I guess this can be considered a known issue.
Sign in to join this conversation.
No reviewers
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
Interest: X11
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
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#107260
No description provided.