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
5e208d57
Kaydet (Commit)
5e208d57
authored
May 18, 2013
tarafından
zyegfryed
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Fixed #20433: Extract catalog compilation code from javascript_catalog view.
üst
9012a9e2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
31 deletions
+37
-31
i18n.py
django/views/i18n.py
+37
-31
No files found.
django/views/i18n.py
Dosyayı görüntüle @
5e208d57
...
...
@@ -184,38 +184,8 @@ def render_javascript_catalog(catalog=None, plural=None):
return
http
.
HttpResponse
(
template
.
render
(
context
),
'text/javascript'
)
def
null_javascript_catalog
(
request
,
domain
=
None
,
packages
=
None
):
"""
Returns "identity" versions of the JavaScript i18n functions -- i.e.,
versions that don't actually do anything.
"""
return
render_javascript_catalog
()
def
javascript_catalog
(
request
,
domain
=
'djangojs'
,
packages
=
None
):
"""
Returns the selected language catalog as a javascript library.
Receives the list of packages to check for translations in the
packages parameter either from an infodict or as a +-delimited
string from the request. Default is 'django.conf'.
Additionally you can override the gettext domain for this view,
but usually you don't want to do that, as JavaScript messages
go to the djangojs domain. But this might be needed if you
deliver your JavaScript source from Django templates.
"""
def
get_javascript_catalog
(
locale
,
domain
,
packages
):
default_locale
=
to_locale
(
settings
.
LANGUAGE_CODE
)
locale
=
to_locale
(
get_language
())
if
request
.
GET
and
'language'
in
request
.
GET
:
if
check_for_language
(
request
.
GET
[
'language'
]):
locale
=
to_locale
(
request
.
GET
[
'language'
])
if
packages
is
None
:
packages
=
[
'django.conf'
]
if
isinstance
(
packages
,
six
.
string_types
):
packages
=
packages
.
split
(
'+'
)
packages
=
[
p
for
p
in
packages
if
p
==
'django.conf'
or
p
in
settings
.
INSTALLED_APPS
]
t
=
{}
paths
=
[]
...
...
@@ -296,4 +266,40 @@ def javascript_catalog(request, domain='djangojs', packages=None):
for
k
,
v
in
pdict
.
items
():
catalog
[
k
]
=
[
v
.
get
(
i
,
''
)
for
i
in
range
(
maxcnts
[
msgid
]
+
1
)]
return
catalog
,
plural
def
null_javascript_catalog
(
request
,
domain
=
None
,
packages
=
None
):
"""
Returns "identity" versions of the JavaScript i18n functions -- i.e.,
versions that don't actually do anything.
"""
return
render_javascript_catalog
()
def
javascript_catalog
(
request
,
domain
=
'djangojs'
,
packages
=
None
):
"""
Returns the selected language catalog as a javascript library.
Receives the list of packages to check for translations in the
packages parameter either from an infodict or as a +-delimited
string from the request. Default is 'django.conf'.
Additionally you can override the gettext domain for this view,
but usually you don't want to do that, as JavaScript messages
go to the djangojs domain. But this might be needed if you
deliver your JavaScript source from Django templates.
"""
locale
=
to_locale
(
get_language
())
if
request
.
GET
and
'language'
in
request
.
GET
:
if
check_for_language
(
request
.
GET
[
'language'
]):
locale
=
to_locale
(
request
.
GET
[
'language'
])
if
packages
is
None
:
packages
=
[
'django.conf'
]
if
isinstance
(
packages
,
six
.
string_types
):
packages
=
packages
.
split
(
'+'
)
catalog
,
plural
=
get_javascript_catalog
(
locale
,
domain
,
packages
)
return
render_javascript_catalog
(
catalog
,
plural
)
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