Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
D
django
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
django
Commits
9e83f30c
Kaydet (Commit)
9e83f30c
authored
Mar 20, 2015
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #24515 -- Fixed DjangoTranslation plural handling
üst
aea02ddf
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
2 deletions
+13
-2
trans_real.py
django/utils/translation/trans_real.py
+2
-1
tests.py
tests/i18n/tests.py
+11
-1
No files found.
django/utils/translation/trans_real.py
Dosyayı görüntüle @
9e83f30c
...
...
@@ -104,7 +104,6 @@ class DjangoTranslation(gettext_module.GNUTranslations):
self
.
__language
=
language
self
.
__to_language
=
to_language
(
language
)
self
.
__locale
=
to_locale
(
language
)
self
.
plural
=
lambda
n
:
int
(
n
!=
1
)
self
.
_init_translation_catalog
()
self
.
_add_installed_apps_translations
()
...
...
@@ -132,6 +131,7 @@ class DjangoTranslation(gettext_module.GNUTranslations):
# provides merge support for NullTranslations()
translation
.
_catalog
=
{}
translation
.
_info
=
{}
translation
.
plural
=
lambda
n
:
int
(
n
!=
1
)
return
translation
def
_init_translation_catalog
(
self
):
...
...
@@ -144,6 +144,7 @@ class DjangoTranslation(gettext_module.GNUTranslations):
# gettext will raise an IOError (refs #18192).
use_null_fallback
=
False
translation
=
self
.
_new_gnu_trans
(
localedir
,
use_null_fallback
)
self
.
plural
=
translation
.
plural
self
.
_info
=
translation
.
_info
.
copy
()
self
.
_catalog
=
translation
.
_catalog
.
copy
()
...
...
tests/i18n/tests.py
Dosyayı görüntüle @
9e83f30c
...
...
@@ -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
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment