Weblate issue - Java format Enforced - translations can’t be saved
Hi @wmontwe For the two strings below, the Weblate UI shows: "Java format Enforced The following format strings are missing: %d" However %d is found in the translations for the plural forms. The translations can’t be saved.
https://hosted.weblate.org/translate/tb-android/account-setup/fr/?q=state%3A%3Ctranslated&offset=1
For Android apps, the Java Format check is enabled by default. It ensures that translations keep required parts of the original text, such as “%d” (which represents a number).
All plural versions of a text must include that placeholder exactly as in the source. This rule is mainly there to prevent runtime crashes and to make sure the app handles numbers correctly in every language.
A runtime crash means the app suddenly closes while someone is using it. This interrupts what the person was doing, can lead to lost data, and creates a poor user experience. Preventing these crashes is the main reason Weblate does not allow saving a translation when a required placeholder is missing.
Because this rule comes from how Android works, it’s sometimes necessary to accept wording that isn’t perfectly natural in every language. Keeping the app stable and preventing crashes is more important than having the ideal phrasing in every case.
Hi @wmontwe Indeed, and I agree with you. However it doesn’t address the issue at hand. For these strings, the %d variable is present in the translations when it is in the source, yet the translations can’t be saved. Also, because of this inability to save the translations, are we pushing English in the French UI?
I added the missing %d variable, that allows to save the translation.
Hi @wmontwe Thanks for that. You added in the singular form a %d that is not present in the English singular. The fact that it was missing in the source is the reason translators won’t add it in the singular form translation. I’d advise that when a variable is needed in a translation field, that variable should also be present in the source field :)