After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 552053 - Using two types of plural form
Using two types of plural form
Status: RESOLVED FIXED
Product: nautilus
Classification: Core
Component: general
3.2.x
Other All
: Normal normal
: 3.2
Assigned To: Nautilus Maintainers
Nautilus Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-09-12 23:42 UTC by Yuriy Penkin
Modified: 2012-08-21 01:57 UTC
See Also:
GNOME target: ---
GNOME version: 3.1/3.2


Attachments
use plural form only for messages with explicit number (3.33 KB, patch)
2008-11-09 14:40 UTC, Yuriy Penkin
none Details | Review
use plural form only for messages with explicit number (3.70 KB, patch)
2012-08-20 22:41 UTC, William Jon McCann
committed Details | Review

Description Yuriy Penkin 2008-09-12 23:42:40 UTC
Please describe the problem:
When I translate nautilus I found two types of plural form:
1. the plural form with explicit number in a message
2. the plural form without one.

for English 1) and 2) the same, but for some other languages it's not the same.
for example, the translation of message "Copying %'d file (in \"%B\") to \"%B\"" (case 1) to Russian is
- Копируется 20 файлов (из \"%B\") в \"%B\" (for n=20)
- Копируется 21 файл (из \"%B\") в \"%B\" (for n=21)
- Копируется 22 файла (из \"%B\") в \"%B\" (for n=22)
but the plural form of message "Copying file (in \"%B\") to \"%B\" (case 2) should be translated as
- Копируется файл (из \"%B\") в \"%B\" (for n=1)
- Копируются файлы (из \"%B\") в \"%B\" (for n>1)

As you see two types of plural form are not incompatibled for Russian and I think for some other languages.

I found 4 message of plural form 2):

#: ../src/file-manager/fm-directory-view.c:7309
#, fuzzy, c-format
msgid "Move the selected folder out of the trash to \"%s\""
msgid_plural "Move the selected folders out of the trash to \"%s\""

#: ../src/file-manager/fm-directory-view.c:7313
#, fuzzy, c-format
msgid "Move the selected folder out of the trash"
msgid_plural "Move the selected folders out of the trash"

#: ../src/file-manager/fm-directory-view.c:7319
#, fuzzy, c-format
msgid "Move the selected file out of the trash to \"%s\""
msgid_plural "Move the selected files out of the trash to \"%s\""

#: ../src/file-manager/fm-directory-view.c:7323
#, fuzzy, c-format
msgid "Move the selected file out of the trash"
msgid_plural "Move the selected files out of the trash"

Steps to reproduce:
1. 
2. 
3. 


Actual results:


Expected results:


Does this happen every time?


Other information:
Comment 1 Christian Neumair 2008-09-13 09:43:04 UTC
Thanks for your bug report.

I do understand that plural formats may change if the number is not included in the message string (i.e. form 2) - but what is the actual issue? Isn't it possible to specify which form to use in the .po file for a given string?
Comment 2 Yuriy Penkin 2008-09-13 16:28:43 UTC
(In reply to comment #1)
> 
> Isn't it possible to specify which form to use in the .po file for a given 
> string?
> 

Wnen we use only one type of plural form it's ok, but when we use both we have a problem.
In Russian the plural form with explicit number we can describe like this:
 
Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);

when n=1,21,31,41, ..., 91 we have the one form

but when we use type plural form type 2 we need one form for n=1 and one form for n>1. thus for n=21,31, ..., 91 there is no way to determine which form we should use.

e.g. translation of "Copying %'d file (in \"%B\")
n=1 Копируется 1 файл (из \"%B\") в \"%B\"
n=21 Копируется 21 *файл* (из \"%B\") в \"%B\"

but translation of "Copying file (in \"%B\")
n=1 Копируется файл (из \"%B\") в \"%B\"
n=21 Копируются *файлы* (из \"%B\") в \"%B\"
Comment 3 Christian Neumair 2008-09-13 22:56:28 UTC
I think I understand the issue. But I do not see any problem or "bug" here, because you could redefine the plural form to achieve both forms, for instance using:

"Plural-Forms: nplurals=4; plural= (n=1) ? 0 : (n%10==1 && n%100!=11 ? 1 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 2 : 3);\n"

That way, you could use

msgid "Copying %'d file (in \"%B\") to \"%B\""
msgid_plural "Copying %'d files (in \"%B\") to \"%B\""
msgstr[0] "Копируется %'d файл (из «%B») в «%B»"
msgstr[1] "Копируется %'d файл (из «%B») в «%B»"
msgstr[2] "Копируются %'d файла (из «%B») в «%B»"
msgstr[3] "Копируется %'d файлов (из «%B») в «%B»"

Note that [0] would be used for 1 only, so you have to duplicate [0] and [1] each time a number is specified.

In contrast, the following is an example how you achieve n=1 vs. n!=1, i.e. when no explicit numbers are specified:

msgid "Copying file (in \"%B\") to \"%B\""
msgid_plural "Copying files (in \"%B\") to \"%B\""
msgstr[0]="Копируется файл (из \"%B\") в \"%B\""
msgstr[1]="Копируются файлы (из \"%B\") в \"%B\""
msgstr[2]="Копируются файлы (из \"%B\") в \"%B\""
msgstr[3]="Копируются файлы (из \"%B\") в \"%B\""

If you decide to use the above scheme, don't forget to convert the old translations.

Does that sounds reasonable? 
Comment 4 Nickolay V. Shmyrev 2008-09-14 08:41:31 UTC
No, it's not reasonable. Forms are fixed for a language, modification will confuse translators.
Comment 5 Christian Neumair 2008-09-14 13:56:37 UTC
So the solution is not to use ngettext for n=1 vs. n>1 decisions if the number does not occur explicitly in the string?
Comment 6 Nickolay V. Shmyrev 2008-09-14 16:36:44 UTC
I think this is the solution. We had this in some package, I don't remember which exactly.
Comment 7 Yuriy Penkin 2008-11-09 14:40:57 UTC
Created attachment 122264 [details] [review]
use plural form only for messages with explicit number
Comment 8 Allan Day 2010-06-20 21:27:57 UTC
Changing component as a part of ongoing bug reorganisation work.
Comment 9 André Klapper 2011-08-10 11:35:33 UTC
Patch available, setting TM.
Comment 10 William Jon McCann 2012-08-20 22:41:24 UTC
Created attachment 221936 [details] [review]
use plural form only for messages with explicit number
Comment 11 Cosimo Cecchi 2012-08-21 00:08:22 UTC
Review of attachment 221936 [details] [review]:

Looks good to me.
Comment 12 William Jon McCann 2012-08-21 01:57:13 UTC
Attachment 221936 [details] pushed as c59ee71 - use plural form only for messages with explicit number