Proper handling of UI messages for translation (i18n) in CPP code. #92758
Labels
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
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#92758
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
'Generated' strings (e.g. using C-style
printf
strings) need to be known (as much as possible) from translators as a unique, complete single item, not as chunks of strings patched together when building the final UI message.E.g (from
AssetCatalogDropController::drop_tooltip_asset_catalog
in asset_catalog_tree_view.cc):This will generate two completely unrelated messages
"Move Catalog"
and"into"
.Move Catalog
could very likely also be an operator name, or a button label, that would require a different translation.into
might have ten different ways to be translated in other languages, how do they choose? What if many places use that singleinto
message?A C version could be e.g. (pseud-code obviously):
This will generate a full specific message
"Move Catalog '%s' into '%s'"
.Note that this is not only an issue of disambiguation, it is also a critical point for many non-latin languages (RTL languages, languages using alternative signs to quote, etc.).
Changed status from 'Needs Triage' to: 'Confirmed'
Added subscriber: @mont29
For now, I would suggest that Cpp code uses standard C
printf
-like functions to build their custom/dynamic UI messages?Added subscriber: @JulianEisel
Added subscriber: @HooglyBoogly
The issue with
BLI_sprintfN
is that it returns an allocated string output, meaning no small size optimization, and requires calling free later on.Using
std::string
is so much nicer than that, because of RAII, etc.Maybe a better solution would be a string format function with a
std::string
output.Added subscriber: @GeorgiaPacific
Added subscriber: @pioverfour
For the record, after trying to mitigate some string issues in D15996, a talk with @HooglyBoogly hinted at the possibility to replace
BLI_sprintfN()
withfmt::format()
, which is already used in Blender and could be generalized to more C++ code for this purpose.This library has the extra advantage that format arguments can be numbered, and reordered in translations if needed.
Damien Picard referenced this issue2023-03-03 16:57:15 +01:00
fmt::format()
has now been used multiple times without any issue AFAIK, I believe this issue can be closed.Indeed!