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
ceca221b
Kaydet (Commit)
ceca221b
authored
Haz 15, 2017
tarafından
Claude Paroz
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #28304 -- Kept SafeData type for pgettext-translated strings
üst
a6b5321c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
9 deletions
+15
-9
trans_real.py
django/utils/translation/trans_real.py
+2
-0
tests.py
tests/i18n/tests.py
+13
-9
No files found.
django/utils/translation/trans_real.py
Dosyayı görüntüle @
ceca221b
...
...
@@ -327,6 +327,8 @@ def pgettext(context, message):
if
CONTEXT_SEPARATOR
in
result
:
# Translation not found
result
=
message
elif
isinstance
(
message
,
SafeData
):
result
=
mark_safe
(
result
)
return
result
...
...
tests/i18n/tests.py
Dosyayı görüntüle @
ceca221b
...
...
@@ -227,19 +227,23 @@ class TranslationTests(SimpleTestCase):
s
=
mark_safe
(
''
)
self
.
assertEqual
(
s
,
gettext
(
s
))
@override_settings
(
LOCALE_PATHS
=
extended_locale_paths
)
def
test_safe_status
(
self
):
"""
Translating a string requiring no auto-escaping
shouldn't change the
"safe" status.
Translating a string requiring no auto-escaping
with gettext or pgettext
shouldn't change the
"safe" status.
"""
s
=
mark_safe
(
'Password'
)
self
.
assertIs
(
type
(
s
),
SafeText
)
trans_real
.
_active
=
local
()
trans_real
.
_translations
=
{}
s1
=
mark_safe
(
'Password'
)
s2
=
mark_safe
(
'May'
)
with
translation
.
override
(
'de'
,
deactivate
=
True
):
self
.
assertIs
(
type
(
gettext
(
s
)),
SafeText
)
self
.
assertEqual
(
'aPassword'
,
SafeText
(
'a'
)
+
s
)
self
.
assertEqual
(
'Passworda'
,
s
+
SafeText
(
'a'
))
self
.
assertEqual
(
'Passworda'
,
s
+
mark_safe
(
'a'
))
self
.
assertEqual
(
'aPassword'
,
mark_safe
(
'a'
)
+
s
)
self
.
assertIs
(
type
(
gettext
(
s1
)),
SafeText
)
self
.
assertIs
(
type
(
pgettext
(
'month name'
,
s2
)),
SafeText
)
self
.
assertEqual
(
'aPassword'
,
SafeText
(
'a'
)
+
s1
)
self
.
assertEqual
(
'Passworda'
,
s1
+
SafeText
(
'a'
))
self
.
assertEqual
(
'Passworda'
,
s1
+
mark_safe
(
'a'
))
self
.
assertEqual
(
'aPassword'
,
mark_safe
(
'a'
)
+
s1
)
self
.
assertEqual
(
'as'
,
mark_safe
(
'a'
)
+
mark_safe
(
's'
))
def
test_maclines
(
self
):
...
...
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