First time here? Check out the FAQ!
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?

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Evgeny's avatar
13.2k
Evgeny
updated 15 years ago, asked 15 years ago

Comments

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.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Evgeny's avatar
13.2k
Evgeny
updated 14 years ago, answered 14 years ago
link

Comments

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.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Aleksandar's avatar
31
Aleksandar
answered 15 years ago
link

Comments

see more comments