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
9e8df02d
Kaydet (Commit)
9e8df02d
authored
Tem 21, 2012
tarafından
Aymeric Augustin
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[py3] Ported django.utils.translation.
üst
17da0aa8
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
17 deletions
+24
-17
trans_real.py
django/utils/translation/trans_real.py
+24
-17
No files found.
django/utils/translation/trans_real.py
Dosyayı görüntüle @
9e8df02d
...
...
@@ -9,7 +9,9 @@ import gettext as gettext_module
from
threading
import
local
from
django.utils.importlib
import
import_module
from
django.utils.encoding
import
smart_str
,
smart_text
from
django.utils.safestring
import
mark_safe
,
SafeData
from
django.utils
import
six
from
django.utils.six
import
StringIO
...
...
@@ -259,12 +261,14 @@ def do_translate(message, translation_function):
def
gettext
(
message
):
return
do_translate
(
message
,
'gettext'
)
def
ugettext
(
message
):
return
do_translate
(
message
,
'ugettext'
)
if
six
.
PY3
:
ugettext
=
gettext
else
:
def
ugettext
(
message
):
return
do_translate
(
message
,
'ugettext'
)
def
pgettext
(
context
,
message
):
result
=
do_translate
(
"
%
s
%
s
%
s"
%
(
context
,
CONTEXT_SEPARATOR
,
message
),
'ugettext'
)
result
=
ugettext
(
"
%
s
%
s
%
s"
%
(
context
,
CONTEXT_SEPARATOR
,
message
))
if
CONTEXT_SEPARATOR
in
result
:
# Translation not found
result
=
message
...
...
@@ -297,20 +301,23 @@ def ngettext(singular, plural, number):
"""
return
do_ntranslate
(
singular
,
plural
,
number
,
'ngettext'
)
def
ungettext
(
singular
,
plural
,
number
):
"""
Returns a unicode strings of the translation of either the singular or
plural, based on the number.
"""
return
do_ntranslate
(
singular
,
plural
,
number
,
'ungettext'
)
if
six
.
PY3
:
ungettext
=
ngettext
else
:
def
ungettext
(
singular
,
plural
,
number
):
"""
Returns a unicode strings of the translation of either the singular or
plural, based on the number.
"""
return
do_ntranslate
(
singular
,
plural
,
number
,
'ungettext'
)
def
npgettext
(
context
,
singular
,
plural
,
number
):
result
=
do_ntranslate
(
"
%
s
%
s
%
s"
%
(
context
,
CONTEXT_SEPARATOR
,
singular
),
"
%
s
%
s
%
s"
%
(
context
,
CONTEXT_SEPARATOR
,
plural
),
number
,
'ungettext'
)
result
=
ungettext
(
"
%
s
%
s
%
s"
%
(
context
,
CONTEXT_SEPARATOR
,
singular
),
"
%
s
%
s
%
s"
%
(
context
,
CONTEXT_SEPARATOR
,
plural
),
number
)
if
CONTEXT_SEPARATOR
in
result
:
# Translation not found
result
=
do_ntranslate
(
singular
,
plural
,
number
,
'ungettext'
)
result
=
ungettext
(
singular
,
plural
,
number
)
return
result
def
all_locale_paths
():
...
...
@@ -440,7 +447,7 @@ def templatize(src, origin=None):
from
django.conf
import
settings
from
django.template
import
(
Lexer
,
TOKEN_TEXT
,
TOKEN_VAR
,
TOKEN_BLOCK
,
TOKEN_COMMENT
,
TRANSLATOR_COMMENT_MARK
)
src
=
s
rc
.
decode
(
settings
.
FILE_CHARSET
)
src
=
s
mart_text
(
src
,
settings
.
FILE_CHARSET
)
out
=
StringIO
()
message_context
=
None
intrans
=
False
...
...
@@ -455,7 +462,7 @@ def templatize(src, origin=None):
content
=
''
.
join
(
comment
)
translators_comment_start
=
None
for
lineno
,
line
in
enumerate
(
content
.
splitlines
(
True
)):
if
line
.
lstrip
()
.
startswith
(
TRANSLATOR_COMMENT_MARK
):
if
line
.
lstrip
()
.
startswith
(
smart_text
(
TRANSLATOR_COMMENT_MARK
)
):
translators_comment_start
=
lineno
for
lineno
,
line
in
enumerate
(
content
.
splitlines
(
True
)):
if
translators_comment_start
is
not
None
and
lineno
>=
translators_comment_start
:
...
...
@@ -570,7 +577,7 @@ def templatize(src, origin=None):
out
.
write
(
' #
%
s'
%
t
.
contents
)
else
:
out
.
write
(
blankout
(
t
.
contents
,
'X'
))
return
out
.
getvalue
()
.
encode
(
'utf-8'
)
return
smart_str
(
out
.
getvalue
()
)
def
parse_accept_lang_header
(
lang_string
):
"""
...
...
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