Make editor's shortcut names translated on-site #99158
Open
+544
−538
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When it's necessary to translate the name of a shortcut, the in-game solution is to automatically translate it when it's displayed (e.g. when the shortcut's name is displayed in a button's tooltip).
The editor code takes advantage of the fact that changing the editor language requires a restart. It translates the name once when the shortcut object is created.
Doing so leads to possible redundant double translations in the editor. It also creates inconsistencies in the way translations are done in the editor and in the game, which is not conducive to improving the translation system.
In this PR:
TTRC()
instead ofTTR()
to mark a shortcut's name.TTRC()
is just a marker and does not translate.TTR()
toTTRC()
. This allows the button to avoid duplicate text automatically, as well as double translations.Note that the disadvantage of changing to
TTRC()
is that it does not support translation contexts. In theory, you still need to manually translate and change the name inNOTIFICATION_TRANSLATION_CHANGED
in such case.In editor codebase, the only place this happens is the tiles editor where we added context for
Line
. The shortcut is for drawing straight lines and needs to be distinguished from representing a line of text.godot/editor/plugins/tiles/tiles_editor_plugin.cpp
Lines 313 to 316 in cb411fa
The translation context here could actually be eliminated if the name itself was more precise. Therefore, I took the liberty of suffixing these shortcuts' names with "Tool".
godot/editor/plugins/tiles/tiles_editor_plugin.cpp
Lines 313 to 316 in 4d20b21