1

How to internationalize counts say for Russian in Django?

In Russian word endings in plural forms change periodically in the following way:

a special pattern till 20:

1 вопрос
2 ...4 вопроса
5 ... 20 вопросов

then for each 10 this repeats until 100:

21 вопрос
22...24 вопроса
25 ... 30 вопросов

Then combined pattern shown above repeats each hundred (where in English only singular form is special).

How would you handle this in Django? We want to translate this software properly into russian and other languages too :)

What other languages have similar issues?

Evgeny's avatar
13.2k
Evgeny
updated 2010-04-04 21:00:26 -0500, asked 2010-04-04 20:55:09 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

2 Answers

1

in gettext system (which is used within Django) - you need to specify in the .po file header - number of plural forms like so:

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

Above there is a formula to calculate number of the plural form to use for each count. Of course number of forms and the formula will depend on the language. Turns out that Polish has four plural forms (singular + three plurals)!

Then for each translation string that needs pluralization (has msgid_plural entry) add

msgstr[0]
msgstr[1]
msgstr[2]

Most likely the first two will already be there.

After .po files are modified this way - in Django you can use rosetta app to facilitate translations. However, there will be some gotchas which will need to be fixed manually, using plain text editor.

Evgeny's avatar
13.2k
Evgeny
updated 2010-05-04 19:11:27 -0500, answered 2010-05-04 19:07:25 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments
1

Serbian has something similar.

I suppose that all slavic group of languages have similar patterns..

pattern till 20:

1 питање (pitanje)

2-20 питања (pitanja)

then for each 10 this repeats until 100:

21 питање (pitanje)

22-30 питања (pitanja)

then after 100, like in Russian... ..combination of above patterns.

100 питања (pitanja)

101 питање (pitanje)

102-120 питања (pitanja)

121 питање (pitanje)

122-130 питања (pitanja)

etc.

Aleksandar's avatar
31
Aleksandar
answered 2010-04-12 23:18:09 -0500
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments