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
49dea416
Kaydet (Commit)
49dea416
authored
Nis 29, 2015
tarafından
Dmitry Medvinsky
Kaydeden (comit)
Tim Graham
Nis 30, 2015
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
[1.8.x] Added translation.override() context manager to docs.
Backport of
cf34ee68
from master
üst
afae8ff9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
0 deletions
+11
-0
translation.txt
docs/topics/i18n/translation.txt
+11
-0
No files found.
docs/topics/i18n/translation.txt
Dosyayı görüntüle @
49dea416
...
@@ -1739,6 +1739,7 @@ will affect code running in the same thread.
...
@@ -1739,6 +1739,7 @@ will affect code running in the same thread.
For example::
For example::
from django.utils import translation
from django.utils import translation
def welcome_translated(language):
def welcome_translated(language):
cur_language = translation.get_language()
cur_language = translation.get_language()
try:
try:
...
@@ -1757,6 +1758,16 @@ which returns the language used in the current thread,
...
@@ -1757,6 +1758,16 @@ which returns the language used in the current thread,
for the current thread, and ``django.utils.translation.check_for_language()``
for the current thread, and ``django.utils.translation.check_for_language()``
which checks if the given language is supported by Django.
which checks if the given language is supported by Django.
To help write more concise code, there is also a context manager
``django.utils.translation.override()`` that stores the current language on
enter and restores it on exit. With it, the above example becomes::
from django.utils import tranlations
def welcome_translated(language):
with translation.override(language):
return translation.ugettext('welcome')
Language cookie
Language cookie
---------------
---------------
...
...
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