diff options
| author | Claude Paroz <claude@2xlibre.net> | 2020-03-10 15:56:32 +0100 |
|---|---|---|
| committer | Carlton Gibson <carlton.gibson@noumenal.es> | 2020-03-10 15:57:36 +0100 |
| commit | d9f1792c7649e9f946f4a3a35a76bddf5a412b8b (patch) | |
| tree | 2798a63da1369dd8ef28b9ede4f399df3f4f0b29 /tests | |
| parent | 525274f79b183ab022675b2801cb26a9368fe1d3 (diff) | |
[3.0.x] Fixed #30439 -- Added support for different plural forms for a language.
Thanks to Michal Čihař for review.
Backport of e3e48b00127c09eafe6439d980a82fc5c591b673 from master
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/i18n/other/locale/fr/LC_MESSAGES/django.mo | bin | 528 -> 580 bytes | |||
| -rw-r--r-- | tests/i18n/other/locale/fr/LC_MESSAGES/django.po | 13 | ||||
| -rw-r--r-- | tests/i18n/tests.py | 16 |
3 files changed, 27 insertions, 2 deletions
diff --git a/tests/i18n/other/locale/fr/LC_MESSAGES/django.mo b/tests/i18n/other/locale/fr/LC_MESSAGES/django.mo Binary files differindex 478338bc88..d86cae8f91 100644 --- a/tests/i18n/other/locale/fr/LC_MESSAGES/django.mo +++ b/tests/i18n/other/locale/fr/LC_MESSAGES/django.mo diff --git a/tests/i18n/other/locale/fr/LC_MESSAGES/django.po b/tests/i18n/other/locale/fr/LC_MESSAGES/django.po index dafb6139ae..7626e5f6d5 100644 --- a/tests/i18n/other/locale/fr/LC_MESSAGES/django.po +++ b/tests/i18n/other/locale/fr/LC_MESSAGES/django.po @@ -14,7 +14,10 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=2; plural=(n != 1)\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n==0 ? 1 : 2);\n" + +# Plural form is purposefully different from the normal French plural to test +# multiple plural forms for one language. #: template.html:3 # Note: Intentional: variable name is translated. @@ -24,4 +27,10 @@ msgstr "Mon nom est %(personne)s." #: template.html:3 # Note: Intentional: the variable name is badly formatted (missing 's' at the end) msgid "My other name is %(person)s." -msgstr "Mon autre nom est %(person)."
\ No newline at end of file +msgstr "Mon autre nom est %(person)." + +msgid "%d singular" +msgid_plural "%d plural" +msgstr[0] "%d singulier" +msgstr[1] "%d pluriel1" +msgstr[2] "%d pluriel2" diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py index ac813b3439..cce32ea86c 100644 --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -125,6 +125,22 @@ class TranslationTests(SimpleTestCase): self.assertEqual(g('%d year', '%d years', 1) % 1, '1 year') self.assertEqual(g('%d year', '%d years', 2) % 2, '2 years') + @override_settings(LOCALE_PATHS=extended_locale_paths) + @translation.override('fr') + def test_multiple_plurals_per_language(self): + """ + Normally, French has 2 plurals. As other/locale/fr/LC_MESSAGES/django.po + has a different plural equation with 3 plurals, this tests if those + plural are honored. + """ + self.assertEqual(ngettext("%d singular", "%d plural", 0) % 0, "0 pluriel1") + self.assertEqual(ngettext("%d singular", "%d plural", 1) % 1, "1 singulier") + self.assertEqual(ngettext("%d singular", "%d plural", 2) % 2, "2 pluriel2") + french = trans_real.catalog() + # Internal _catalog can query subcatalogs (from different po files). + self.assertEqual(french._catalog[('%d singular', 0)], '%d singulier') + self.assertEqual(french._catalog[('%d hour', 0)], '%d heure') + def test_override(self): activate('de') try: |
