I am trying to translate an Android app to Ukrainian but I am facing an issue with plural forms. transifex prevents me from using the number placeholder because in the original text one of the forms omits it.
(notice that the first form does have the placeholder. It needs it because it will also handle numbers like 1, 21, 101)
However, there is no way to insert the placeholder for form “one”. I managed to copy it from another translation but transifex refuses to save the translation as it not present in the original text.
As you can see for, the form of “one” 1, 21, 31, etc. is included in that same form. As a result, that means that in the source string, “one” should be replaced with a variable such as %d. We recommend this practice so that you will be able to handle all the other numbers that follow this rule.
This is also true for other languages that handle more than one number in the singular form (for example French where the singular form is used for a count of 0 and 1).
Please let me know if this helps solve your issue or if I missed anything, and I will get back to you as soon as possible.
Thanks, this could help me resolve the problem and Android documentation confirms that. Maybe I will go with that by asking the owner to change the source text. But, to be honest, this does not feel completely right to me:
Despite the documentation, Android OS itself has an instance of omitting the variable for singular form in default translation but using the variable in the translated string: source, translated. (I found it on my phone in Wi-Fi settings, and it seems to display correctly ). So, I would not consider that outright invalid.
I would guess there might be additional problems would someone try to import those files into Transifex. It might fail during the import or refuse to save the translation with the same error as I am getting now.
Being able to have “Deleted one note” (instead of “Deleted 1 note”) for the English version looks like a valid and useful case to me.
The logic by which Transifex decides that I cannot use the variable %d for singular form seems a bit strange to me:
4.1 I am disallowed to use %d in translation for the singular form because the singular of the source string does not use it. But why does Transifex look at “one” category specifically? The same category in two different languages, as you have mentioned, is not necessarily equivalent. At the same time, I am allowed to use %d in translations for “few” and “many” categories even though these categories are not in the source at all.
4.2 I would assume that the set of variables is actually the same for all plural forms of a string. It is just that not every variable has to be used in every plural form. (So, %d in my examples is always available, but sometimes ignored)
If I got it right, you may consider this change: if a variable is used in one plural form of a string, it should be available for use in all the forms.
First, go to your organization settings, and in the translation checks section, navigate to “Android String Resources (.xml) checks”. In the drop-down, you can find the “Variable substitution specifiers (like “%s”) are preserved in the translations” check, which will be set to produce an error. You can change that to a warning and then hit save.
This will allow you to have “one” in the source string while using a variable in the translation, as seen below: