[i18n] Confused about using plural forms
Bug #1184810 reported by
Renato Araujo Oliveira Filho
This bug affects 4 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ubuntu-ui-toolkit (Ubuntu) |
Fix Released
|
Medium
|
Tim Peeters |
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)"
Related branches
lp:~tpeeters/ubuntu-ui-toolkit/fixI18nDocs
- ubuntu-sdk-build-bot: Approve (continuous-integration)
- Cris Dywan: Approve
-
Diff: 25 lines (+5/-3)1 file modifiedsrc/Ubuntu/Components/plugin/i18n.cpp (+5/-3)
Changed in ubuntu-ui-toolkit: | |
assignee: | nobody → Tim Peeters (tpeeters) |
Changed in ubuntu-ui-toolkit: | |
status: | Confirmed → In Progress |
Changed in ubuntu-ui-toolkit: | |
status: | In Progress → Confirmed |
Changed in ubuntu-ui-toolkit: | |
importance: | High → Medium |
Changed in ubuntu-ui-toolkit: | |
assignee: | Tim Peeters (tpeeters) → nobody |
Changed in ubuntu-ui-toolkit (Ubuntu): | |
importance: | Undecided → Medium |
status: | New → Confirmed |
no longer affects: | ubuntu-ui-toolkit |
Changed in ubuntu-ui-toolkit (Ubuntu): | |
assignee: | nobody → Tim Peeters (tpeeters) |
Changed in ubuntu-ui-toolkit (Ubuntu): | |
status: | Confirmed → In Progress |
Changed in ubuntu-ui-toolkit (Ubuntu): | |
status: | In Progress → Fix Committed |
To post a comment you must log in.
Even when using gettext the parameter needs to be passed twice:
An example for the us of this function is:
printf (ngettext ("%d file removed", "%d files removed", n), n);
Please note that the numeric value n has to be passed to the printf function as well. It is not sufficient to pass it only to ngettext.
So we need to update our docs to match the way you are using it, or change the implementation of tr() to do that automatically. Still need to evaluate the consequences of the latter solution.