Comment 5 for bug 1184810

Revision history for this message
dobey (dobey) wrote : Re: [i18n] Plural form does not work as documented

I think the documentation might need to be fixed, but the implementation seems fine to me. For the general case, it's not possible to automatically insert the "count", as the string may have multiple format specifiers where the numeric value is not the first argument. For instance, the following example would break, if the substitution was done automatically:

tr("Folder %1 has %2 file", "Folder %1 has %2 files", count)

In this case, %1 is the name of the folder, while %2 is the count. If the implementation were to return the result of the gettext call, as a QString with .arg(count) applied to it first, the result would be incorrect.

Maybe it should be made more explicit in the documentation that the API follows the standard QString API expectations here, and does not automatically insert count or contextual values in the string result of tr() calls, but I don't think the implementation should be changed.