#23520: Custom Plural-Forms is ignored in django.po
--------------------------------------+-----------------------------------
Reporter: aruseni | Owner: nobody
Type: Uncategorized | Status: new
Component: Internationalization | Version: 1.7
Severity: Normal | Keywords: gettext, plural-forms
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------+-----------------------------------
I want to use a custom Plural-Forms scheme in my django.po for Russian,
but when I change it, it does not affect the results of ungettext.
I’ve found out that if I use the same translation file without Django,
Plural-Forms works correctly.
Here is the django.po file.
{{{
msgid ""
msgstr ""
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2014-09-18 01:26+0000\n"
"Language: ru\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=4; plural=(n==1 ? 0 : n%10==1 && n%100!=11 ? 1 :
n"
"%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 2 : 3)\n"
#: testapp/test.py:5
#, python-format
msgid "One new notification."
msgid_plural "%(count)s new notifications."
msgstr[0] "Одно новое оповещение."
msgstr[1] "%(count)s новое оповещение."
msgstr[2] "%(count)s новых оповещения."
msgstr[3] "%(count)s новых оповещений."
}}}
If I run this
{{{#!python
import gettext
filename = "testp/conf/locale/ru/LC_MESSAGES/django.mo"
trans = gettext.GNUTranslations(open( filename, "rb" ) )
trans.install()
def translated_message(notifications_count):
return trans.ungettext(
"One new notification.",
"%(count)s new notifications.",
notifications_count
) % {"count": notifications_count}
print translated_message(1)
print translated_message(2)
print translated_message(5)
print translated_message(51)
}}}
The following is printed:
{{{
Одно новое оповещение.
2 новых оповещения.
5 новых оповещений.
51 новое оповещение.
}}}
And this is exactly what I expect to be the result of ungettext.
But the output is different when the same compiled translation file
(django.mo) is used in a Django project.
With django.utils.translation.ungettext it changes to this:
{{{
Одно новое оповещение.
2 новое оповещение.
5 новых оповещения.
Одно новое оповещение.
}}}
It obviously means that in this case the forms (msgstr) are read
correctly, but Plural-Forms is ignored (i.e. the regular scheme for
Russian language is used instead of what I have defined).
--
Ticket URL: <https://code.djangoproject.com/ticket/23520>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/050.c2d953aaf5bc3d33b630c1c22ba955de%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.