Open CantyCanadian opened 1 year ago
For the sake of an example, I just coded this using my homebrewed solution. Though, like I said, having it be default would be sweet.
One issue with implementing this is making it available in core nodes such as Button. You'd want a way to be able to toggle between a string input and a translation key input in a seamless manner (without impacting the underlying type, that is). The way the property was chosen also needs to be persisted to version control, so that other people cloning the project will see the same thing as you.
Also, when using gettext translations, you're encouraged to use English text as a source string directly. This approach may not gel as well with this proposal.
Describe the project you are working on
All of my projects would love to have that.
Describe the problem or limitation you are having in your project
Currently, using localization is a bit of a pain. If you wish to link a localization string in inspector, you have to hand-type the key in a string box and pray you haven't mistyped it. Having a way to see all the keys as a dropdown and select the one you wish to have would remove the magic string-y aspect of it.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
Having a way to hint to a string that it is a localization key would be amazing. We already have hints for translation maps and locale id, so it's weird that keys don't have one as well. That would prevent human error in inputting the keys, but could also now include warnings if a key no longer exists but is referenced. If we also added the ability to support nesting (if a key is "Category/Name", then the dropdown has Category, which drops down all the sub-keys), then it would allow larger games to use the system since they wouldn't need to go through hundreds of keys to find the right one.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
Just like how LocaleId works as a propertyhint, we could add a button on the right of the string box that opens either a window or a dropdown with all the current keys, setup in a tree that supports categories/nesting. Selecting a key will make the string box have that key.
If this enhancement will not be used often, can it be worked around with a few lines of script?
I believe this can be worked around with an editor plugin. However, having it so it updates the key list dynamically might need some kind of editor hook.
Is there a reason why this should be core and not an add-on in the asset library?
Localization is already a critical component of the engine that is supported out of the box. I believe that it needs a few rounds of QoL to make it easier to use before it becomes second nature to add localization in one's game.