#24515: Plural handling broken
------------------------------------------------+------------------------
Reporter: claudep | Owner: nobody
Type: Bug | Status: new
Component: Internationalization | Version: 1.8rc1
Severity: Release blocker | Keywords:
Triage Stage: Accepted | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------------+------------------------
Translation of plural strings is currently not following the plural
equation from the po files and enforce the English default equation.
{{{
#!diff
Test case:diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index ad23861..65aedc0 100644
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -30,7 +30,7 @@ from django.utils.translation import (
get_language, get_language_from_request, get_language_info, gettext,
gettext_lazy, ngettext_lazy, npgettext, npgettext_lazy, pgettext,
pgettext_lazy, string_concat, to_locale, trans_real, ugettext,
- ugettext_lazy, ungettext_lazy,
+ ugettext_lazy, ungettext, ungettext_lazy,
)
from .forms import CompanyForm, I18nForm, SelectDateForm
@@ -57,6 +57,16 @@ def patch_formats(lang, **settings):
class TranslationTests(TestCase):
+ @translation.override('fr')
+ def test_plural(self):
+ """
+ Test plurals with ungettext. French differs from English in that
0 is singular.
+ """
+ self.assertEqual(ungettext("%d year", "%d years", 0) % 0, "0
année")
+ self.assertEqual(ungettext("%d year", "%d years", 2) % 2, "2
années")
+ self.assertEqual(ungettext("%(size)d byte", "%(size)d bytes", 0)
% {'size': 0}, "0 octet")
+ self.assertEqual(ungettext("%(size)d byte", "%(size)d bytes", 2)
% {'size': 2}, "2 octets")
+
def test_override(self):
activate('de')
try:
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/24515>
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.51eb4bb961a1030d8553b0baf609110f%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.