transifex / transifex-old-core

Translation workflow & crowdsourcing for agile teams. Older, open-source codebase of Transifex.com
https://www.transifex.com/
GNU General Public License v2.0
5 stars 5 forks source link

Wrong expression check for some singular forms #287

Open claudep opened 10 years ago

claudep commented 10 years ago

Take this translation unit:

msgid "a minute from now"
msgid_plural "%(count)s minutes from now"

In languages where the first translation form in the plural definitions is not only for one element (e.g Lithuanian), gettext requires that the placeholder (%(count)s here) is also in the msgstr[0] content. Unfortunately in Transifex, doing so raises an unvalid error (Error:The expression '%(count)s' is not present in the original phrase.).

uruz commented 10 years ago

I can confirm the issue. I have faced this problem trying to translate django into Russian. Russian has three forms, first form is used for any number that number%10 == 1 && number != 11, so I cannot just drop the placeholder %(count)s from the msgstr[0]. So, this is effectively blocking me from changing Russian translation of some strings that have no placeholder in msgid.

Bashar commented 10 years ago

I also confirm the issue, happened with me while trying to translate django-two-factor-auth into arabic and had forcibly placed the expression although its not needed

dbkblk commented 10 years ago

I also have this issue. Example: In english: Rice will give +15% more food In french : Le riz permet d'obtenir + 15% de nourriture. = ERROR :( % d is not present in the translation.

diegobz commented 9 years ago

@claudep Do you have any idea on how we can determinate which languages should or should not require it?

claudep commented 9 years ago

Looking at plural strings (http://docs.translatehouse.org/projects/localization-guide/en/latest/l10n/pluralforms.html), I think it affects all languages where the equation preceding the ? 0 contains && or ||.

diegobz commented 9 years ago

Uhmm that's kind tough to rely on. I'm trying to find a good reference about the matter. I searched in the gettext docs but didn't have success. If you guys have any hint, let me know.

claudep commented 9 years ago

gettext does indeed apply some clever stuff when deciding if format checking between msgstr and msgid[0] must be strict or not (see check_msgid_msgstr_format_i in format.c). If you fear entering this track, I'd then suggest to simply be more liberal when accepting a format string in msgid[0] if msgstr[0] doesn't have one (maybe check against msgstr[1]?).

diegobz commented 9 years ago

@claudep that could be an option. We will need to investigate further. However I can tell it will require changes in the way our validators are implemented in general. Right now it just takes 1 source string and 1 translation string into account for every check.

sc0w commented 4 years ago

years later... and I experience this issue too.

I can't add %d to languages which have more than one singular, for example in ukranian:

2019-11-13_12-01_1

The currently translation accepted by transifex is erroneus, it gives me this error with "msgfmt -c uk.po":

uk.po:2131: number of format specifications in 'msgid_plural' and
'msgstr[0]' does not match
msgfmt: found 1 fatal error

With %d in singular fixes the problem, it is impossible to do the job at transifex, it says error at website and there is no error.

Russian is also affected, and all the languages which have more than one singular.