manpagez: man pages & more
info gettext
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

12.6 Translating plural forms

Suppose you are translating a PO file, and it contains an entry like this:

#, c-format
msgid "One file removed"
msgid_plural "%d files removed"
msgstr[0] ""
msgstr[1] ""

What does this mean? How do you fill it in?

Such an entry denotes a message with plural forms, that is, a message where the text depends on a cardinal number. The general form of the message, in English, is the msgid_plural line. The msgid line is the English singular form, that is, the form for when the number is equal to 1. More details about plural forms are explained in Additional functions for plural forms.

The first thing you need to look at is the Plural-Forms line in the header entry of the PO file. It contains the number of plural forms and a formula. If the PO file does not yet have such a line, you have to add it. It only depends on the language into which you are translating. You can get this info by using the msginit command (see Creating a New PO File) – it contains a database of known plural formulas – or by asking other members of your translation team.

Suppose the line looks as follows:

"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;\n"

It’s logically one line; recall that the PO file formatting is allowed to break long lines so that each physical line fits in 80 monospaced columns.

The value of nplurals here tells you that there are three plural forms. The first thing you need to do is to ensure that the entry contains an msgstr line for each of the forms:

#, c-format
msgid "One file removed"
msgid_plural "%d files removed"
msgstr[0] ""
msgstr[1] ""
msgstr[2] ""

Then translate the msgid_plural line and fill it in into each msgstr line:

#, c-format
msgid "One file removed"
msgid_plural "%d files removed"
msgstr[0] "%d slika uklonjenih"
msgstr[1] "%d slika uklonjenih"
msgstr[2] "%d slika uklonjenih"

Now you can refine the translation so that it matches the plural form. According to the formula above, msgstr[0] is used when the number ends in 1 but does not end in 11; msgstr[1] is used when the number ends in 2, 3, 4, but not in 12, 13, 14; and msgstr[2] is used in all other cases. With this knowledge, you can refine the translations:

#, c-format
msgid "One file removed"
msgid_plural "%d files removed"
msgstr[0] "%d slika je uklonjena"
msgstr[1] "%d datoteke uklonjenih"
msgstr[2] "%d slika uklonjenih"

You noticed that in the English singular form (msgid) the number placeholder could be omitted and replaced by the numeral word “one”. Can you do this in your translation as well?

msgstr[0] "jednom datotekom je uklonjen"

Well, it depends on whether msgstr[0] applies only to the number 1, or to other numbers as well. If, according to the plural formula, msgstr[0] applies only to n == 1, then you can use the specialized translation without the number placeholder. In our case, however, msgstr[0] also applies to the numbers 21, 31, 41, etc., and therefore you cannot omit the placeholder.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on June 7, 2014 using texi2html 5.0.

© manpagez.com 2000-2024
Individual documents may contain additional copyright information.