mozilla / pontoon

Mozilla's Localization Platform
https://pontoon.mozilla.org
BSD 3-Clause "New" or "Revised" License
1.45k stars 527 forks source link

Avoid translation of strings (and parts of strings) that should not be translated #3043

Open jakobkappel opened 9 months ago

jakobkappel commented 9 months ago

It is possible to add translations for source strings where the comment asks that the string (or parts of it) should not be translated.

Consequently some languages translate strings (or parts of them) that should not be translated.

E.g.

True

COMMENT Shows when boolean value for an option is True. True should not be translated.

https://transvision.mozfr.org/string/?entity=toolkit/toolkit/about/aboutWebauthn.ftl:about-webauthn-auth-info-true&repo=gecko_strings

mathjazz commented 9 months ago

We'd need some sort've semantic comments for that (perhaps something like this can help, /cc @eemeli). Then we could add checks to make sure the strings don't get translated or even translate them.

There are usually edge-cases, though - which is why strings are this are even exposed for localization.

eemeli commented 9 months ago

One way to handle this would indeed be to support a property like @translate no on a message. That would also provide support for other cases where for one reason or another we want a string to be defined within the localization, but want it to always and in all locales be the same.

Another way would be to change how we treat and display literal values in Pontoon. Right now, a Fluent string like

key = This is always { "True" }.

is presented to a translator as

This is always True.

i.e. discarding the literal value trappings. If instead we were to keep non-empty literals as placeholders, then the message would be shown as

This is always { "True" }.

which, in particular if the message included a comment as suggested above, would far more likely keep the value untouched.