Ask Your Question
1

How to internationalize counts say for Russian in Django?

asked 2010-04-04 20:55:09 -0500

Evgeny gravatar image

updated 2010-04-04 21:00:26 -0500

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?

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
1

answered 2010-05-04 19:07:25 -0500

Evgeny gravatar image

updated 2010-05-04 19:11:27 -0500

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.

edit flag offensive delete link more
1

answered 2010-04-12 23:18:09 -0500

Aleksandar gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2010-04-04 20:55:09 -0500

Seen: 1,678 times

Last updated: May 04 '10