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
432339a7
Kaydet (Commit)
432339a7
authored
May 28, 2012
tarafından
Julien Phalip
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #18393 -- Prevented blocktrans to crash when a variable name is badly formatted.
üst
a535040b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
2 deletions
+23
-2
i18n.py
django/templatetags/i18n.py
+1
-1
django.mo
...egressiontests/i18n/other/locale/fr/LC_MESSAGES/django.mo
+0
-0
django.po
...egressiontests/i18n/other/locale/fr/LC_MESSAGES/django.po
+7
-0
tests.py
tests/regressiontests/i18n/tests.py
+15
-1
No files found.
django/templatetags/i18n.py
Dosyayı görüntüle @
432339a7
...
@@ -148,7 +148,7 @@ class BlockTranslateNode(Node):
...
@@ -148,7 +148,7 @@ class BlockTranslateNode(Node):
context
.
pop
()
context
.
pop
()
try
:
try
:
result
=
result
%
data
result
=
result
%
data
except
KeyError
:
except
(
KeyError
,
ValueError
)
:
with
translation
.
override
(
None
):
with
translation
.
override
(
None
):
result
=
self
.
render
(
context
)
result
=
self
.
render
(
context
)
return
result
return
result
...
...
tests/regressiontests/i18n/other/locale/fr/LC_MESSAGES/django.mo
Dosyayı görüntüle @
432339a7
No preview for this file type
tests/regressiontests/i18n/other/locale/fr/LC_MESSAGES/django.po
Dosyayı görüntüle @
432339a7
...
@@ -17,5 +17,11 @@ msgstr ""
...
@@ -17,5 +17,11 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
#: template.html:3
#: template.html:3
# Note: Intentional: variable name is translated.
msgid "My name is %(person)s."
msgid "My name is %(person)s."
msgstr "Mon nom est %(personne)s."
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
tests/regressiontests/i18n/tests.py
Dosyayı görüntüle @
432339a7
...
@@ -270,10 +270,11 @@ class TranslationTests(TestCase):
...
@@ -270,10 +270,11 @@ class TranslationTests(TestCase):
self
.
assertEqual
(
to_language
(
'sr_Lat'
),
'sr-lat'
)
self
.
assertEqual
(
to_language
(
'sr_Lat'
),
'sr-lat'
)
@override_settings
(
LOCALE_PATHS
=
(
os
.
path
.
join
(
here
,
'other'
,
'locale'
),))
@override_settings
(
LOCALE_PATHS
=
(
os
.
path
.
join
(
here
,
'other'
,
'locale'
),))
def
test_bad_placeholder
(
self
):
def
test_bad_placeholder
_1
(
self
):
"""
"""
Error in translation file should not crash template rendering
Error in translation file should not crash template rendering
(
%(person)
s is translated as
%(personne)
s in fr.po)
(
%(person)
s is translated as
%(personne)
s in fr.po)
Refs #16516.
"""
"""
from
django.template
import
Template
,
Context
from
django.template
import
Template
,
Context
with
translation
.
override
(
'fr'
):
with
translation
.
override
(
'fr'
):
...
@@ -281,6 +282,19 @@ class TranslationTests(TestCase):
...
@@ -281,6 +282,19 @@ class TranslationTests(TestCase):
rendered
=
t
.
render
(
Context
({
'person'
:
'James'
}))
rendered
=
t
.
render
(
Context
({
'person'
:
'James'
}))
self
.
assertEqual
(
rendered
,
'My name is James.'
)
self
.
assertEqual
(
rendered
,
'My name is James.'
)
@override_settings
(
LOCALE_PATHS
=
(
os
.
path
.
join
(
here
,
'other'
,
'locale'
),))
def
test_bad_placeholder_2
(
self
):
"""
Error in translation file should not crash template rendering
(
%(person)
misses a 's' in fr.po, causing the string formatting to fail)
Refs #18393.
"""
from
django.template
import
Template
,
Context
with
translation
.
override
(
'fr'
):
t
=
Template
(
'{
%
load i18n
%
}{
%
blocktrans
%
}My other name is {{ person }}.{
%
endblocktrans
%
}'
)
rendered
=
t
.
render
(
Context
({
'person'
:
'James'
}))
self
.
assertEqual
(
rendered
,
'My other name is James.'
)
class
FormattingTests
(
TestCase
):
class
FormattingTests
(
TestCase
):
...
...
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