idle sign
idle sign

Reputation: 1174

Qt: n param of QTranslator::translate() for non-singulars

Qt QTranslator::translate() documentation declares that

If n is not -1, it is used to choose an appropriate form for the translation (e.g. "%n file found" vs. "%n files found").

It seems that there is no way to translate "%n men answered %n questions" as one string (i.e. I need to perform 2 QTranslator::translate() calls), or am I wrong?

Upvotes: 3

Views: 437

Answers (1)

laalto
laalto

Reputation: 152817

I'd advise against attempting to use multiple numerus forms in a single translatable string.

  • It's tricky, involving more than one call to tr().
  • It's complex. Some languages can have more than two numerus forms and the translation space grows in O(n^m) where n is the number of numerus forms in language and m is the number of number forms in your string to be translated string. Case in point: Arabic has six numerus forms and if you have two %ns in your string, you'll need 36 different translations.

So, better to structure your translatable strings so that max one %n is needed per string.

Upvotes: 5

Related Questions