Loading docs/topics/i18n/translation.txt +11 −0 Original line number Diff line number Diff line Loading @@ -1756,6 +1756,7 @@ will affect code running in the same thread. For example:: from django.utils import translation def welcome_translated(language): cur_language = translation.get_language() try: Loading @@ -1774,6 +1775,16 @@ which returns the language used in the current thread, for the current thread, and ``django.utils.translation.check_for_language()`` 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 --------------- Loading Loading
docs/topics/i18n/translation.txt +11 −0 Original line number Diff line number Diff line Loading @@ -1756,6 +1756,7 @@ will affect code running in the same thread. For example:: from django.utils import translation def welcome_translated(language): cur_language = translation.get_language() try: Loading @@ -1774,6 +1775,16 @@ which returns the language used in the current thread, for the current thread, and ``django.utils.translation.check_for_language()`` 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 --------------- Loading