godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.08k stars 69 forks source link

Empty string markers for translations #9139

Open Ovnuniarchos opened 4 months ago

Ovnuniarchos commented 4 months ago

Describe the project you are working on

A GUI-heavy softsynth/tracker.

Describe the problem or limitation you are having in your project

Due to space constraints, many texts in Spanish must be heavily reduced, lowering their clarity. That is solved through tooltips. In English, those texts need not be reduced and the tooltip becomes visual noise.

Those tooltips could be hidden if the TranslationServer was able to output an empty string, but the fallback system ensures that, at least, the original untranslated string is returned.

Also, see issue #1985 .

Describe the feature / enhancement and how it helps to overcome the problem or limitation

A per-project configurable string that, when encountered in a translation file, makes the TranslationServer output an empty string.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

es.po msgid "SOME_TOOLTIP" msgstr "Texto más largo que un día sin pan, para descomprimir la abreviatura." # This shows a tooltip

en.po msgid "SOME_TOOLTIP" msgstr "\<INTENTIONALLY LEFT BLANK>" # This gets translated to "", thus disabling the tooltip.

If this enhancement will not be used often, can it be worked around with a few lines of script?

As the fallback mechanism is implemented at the TranslationServer (which can not be overriden), and not the Translation (which can), I don't se a way to feature this empty translations.

Is there a reason why this should be core and not an add-on in the asset library?

I can't see a way to make an asset out of something that affects the TranslationServer.

Extras

I currently have a working prototype for the 3.x branch.

Mickeon commented 4 months ago

This sounds like an issue that would be solved by a more encompassing and less specific solution. Throwing something on a whim: default tooltips should trim leading and trailing spaces. Since the result of something like " " would be an empty string the tooltip is not shown, as is already the case.

Ovnuniarchos commented 4 months ago

This proposal would affect all translatables. I only used tooltips because it's the most prevalent case in my application.

Issue #1985 has a different use case, for features that make absolutely no sense for a language.

The idea of tooltips auto-trimming texts doesn't attract me. If I wanted to put a space in a tooltip (for whatever reason), auto-trimming would forbid me, whereas this empty string marker is an user-controlled configuration.

Addendum

I forgot to note that, in case the empty string marker was an empty string/not configured, the TranslationServer would use fallback as usual.

alborrajo commented 1 month ago

I've worked around this by using unicode's zero width space character in these empty strings