Issues using poEdit

poEdit for windows, version 1.3.1 (latest at the moment) seems to require some additional steps to recognize plural forms (if you try to edit a term which has plurals, even if you translate it, it doesn't appear in poedit when you move to an other term, as usual, and even if you save, it doesn't).

Plurals Solution #1

So, if you find a plural term, close poedit, open the file you were translating with a normal text editor (no, not Word...), and search for "plural" in it, you find something similar to this:

#: modules/comment.module:187 modules/node.module:89
msgid "1 comment"
msgid_plural "%count comments"
msgstr[0] "1 commento"
msgstr[1] "%count commenti"

simply tranlate the text in msgid (singular form) into msgstr[0], and the text in msgid_plural (plural form) into msgstr[1], save the file, close the editor and return to poedit. Even better, you can do this BEFORE start translating the rest of the file with poedit, translating every occurrance of plural in the same way, in every file, and THEN start using poedit: this way, you will find those strings already translated in poedit, and they don't bother you.

Plurals Solution #2

To use plurals in PO edit you can start with the catalog setting for english and then modify to suit. The syntax is:

nplurals=2; plural=(n != 1);

which gave me what I needed in Swedish translation of:

#: modules/aggregator.module:100;711;722
msgid "1 item"
msgid_plural "items"
msgstr[0] "1 inlägg"
msgstr[1] "%count inlägg"

I tested this in PO Edit 1.3.1 and got the proper GUI response and saved withut error.

Plurals Solution #3

The plural forms to use in PO edit under catalog-settings where you see

nplural=INTEGER; plural=EXPRESSION

Only one form:
Some languages only require one single form. There is no
distinction between the singular and plural form. An appropriate
header entry would look like this:

Plural-Forms: nplurals=1; plural=0;

Languages with this property include:

Finno-Ugric family
Hungarian

Asian family
Japanese, Korean

Turkic/Altaic family
Turkish

Two forms, singular used for one only
This is the form used in most existing programs since it is what
English is using. A header entry would look like this:

Plural-Forms: nplurals=2; plural=n != 1;

(Note: this uses the feature of C expressions that boolean
expressions have to value zero or one.)

Languages with this property include:

Germanic family
Danish, Dutch, English, German, Norwegian, Swedish

Finno-Ugric family
Estonian, Finnish

Latin/Greek family
Greek

Semitic family
Hebrew

Romanic family
Italian, Portuguese, Spanish

Artificial
Esperanto

Two forms, singular used for zero and one
Exceptional case in the language family. The header entry would
be:

Plural-Forms: nplurals=2; plural=n>1;

Languages with this property include:

Romanic family
French, Brazilian Portuguese

Three forms, special case for zero
The header entry would be:

Plural-Forms: nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n != 0 ? 1 : 2;

Languages with this property include:

Baltic family
Latvian

Three forms, special cases for one and two
The header entry would be:

Plural-Forms: nplurals=3; plural=n==1 ? 0 : n==2 ? 1 : 2;

Languages with this property include:

Celtic
Gaeilge (Irish)

Three forms, special case for numbers ending in 1[2-9]
The header entry would look like this:

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

Languages with this property include:

Baltic family
Lithuanian

Three forms, special cases for numbers ending in 1 and 2, 3, 4, except those ending in 1[1-4]
The header entry would look 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;

Languages with this property include:

Slavic family
Croatian, Czech, Russian, Slovak, Ukrainian

Three forms, special case for one and some numbers ending in 2, 3, or 4
The header entry would look like this:

Plural-Forms: nplurals=3; \

plural=n==1 ? 0 : \
                      n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;

Languages with this property include:

Slavic family
Polish

Four forms, special case for one and all numbers ending in 02, 03, or 04
The header entry would look like this:

Plural-Forms: nplurals=4; \
plural=n%100==1 ? 0 : n%100==2 ? 1 : n%100==3 || n%100==4 ? 2 : 3;

Languages with this property include:

Slavic family
Slovenian

Long plural formulae: Those should not be broken into several lines in the header of the PO file. Drupal expects the formula to be on one line. One could consider this a bug.

I don't think that you can use line breaks in POedit either. The text is fixed to keep from breaking the site layout. But this:

nplurals=1; plural=ar;

produces an error. The plural form "ar" is not recognized.

Don't use Notepad

joel_guesclin - February 21, 2005 - 21:57

I first tried Solution #1 using my favorite Windows Editor (Notepad), but thereafter Drupal refused to recognise the language file.
So I tried using Solution #2 with poedit - and that worked!

poEdit recognizes plurals

kefo - March 9, 2005 - 21:02

poEdit supports plural forms (>1.3.0). You must have correct syntax in Catalog/Settings/Plural forms field. Or correct syntax in a source code (po file). Without line breaks. Than you can edit plurals in poEdit (a tab for each plural).

For example correct form for slavic languages is
nplurals=3; plural=n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;

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

Don't use line breaks.

Polish/Polski

archetwist - July 22, 2005 - 14:27

Correct form for Polish is a little more complex:

nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);

Plural Solution for Chinese

kzeng - December 30, 2005 - 05:12

Here is the plural solution for Chinese which is not listed above:

"Plural-Forms: nplurals=2; plural=1;\n"

So if you open the po file using text editor (I think Emeditor is better for the job), you get :

#: modules/archive.module:136
msgid "1 post"
msgid_plural "%count posts"
msgstr[0] "1篇文章"
msgstr[1] "%count 文章"

--------------------------
http://www.kzeng.info

Ukrainian plural form incorrect!

theque - August 5, 2006 - 21:36

Just try to "eval" formula. You'll never get form 0 ;).
So 21, 31 and so on will be translated incorrectly.

Correct formula for ukrainian, russian, etc is:
($n%10==1 && $n%100!=11) ? 0 : (($n%10>=2 && $n%10<=4 && ($n%100<10 || $n%100>=20)) ? 1 : 2)
Take a look at braces

 
 

Drupal is a registered trademark of Dries Buytaert.