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. ** Summary changed: - [i18n] Plural form does not work as documented + [i18n] Confused about using plural forms -- You received this bug notification because you are a member of Ubuntu Touch seeded packages, which is subscribed to ubuntu-ui-toolkit in Ubuntu. https://bugs.launchpad.net/bugs/1184810 Title: [i18n] Confused about using plural forms Status in ubuntu-ui-toolkit package in Ubuntu: Confirmed Bug description: In the i18n component documentation the plural form should be used as: * Translate the given input string \a singular or \a plural (depending on the number of items \a n) * using gettext. Should be called like this: * tr("%n file", "%n files", count) But this does not work as expected: The result string from this expression is: ("%n file" or "%n files" with the "%n" instead the value) checking at the unit2d code I saw that the tr function automatically replaces the %n with the count value, but I am not sure if this is the correct solution. For now I am using "tr("%1 file", "%1 files", count).arg(count)" To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1184810/+subscriptions -- Mailing list: https://launchpad.net/~touch-packages Post to : touch-packages@lists.launchpad.net Unsubscribe : https://launchpad.net/~touch-packages More help : https://help.launchpad.net/ListHelp