mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Added django.utils.translation.override context manager to easily activate and deactivate a language for a code block.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16166 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -8,6 +8,7 @@ from threading import local
|
||||
|
||||
from django.conf import settings
|
||||
from django.template import Template, Context
|
||||
from django.test import TestCase
|
||||
from django.utils.formats import (get_format, date_format, time_format,
|
||||
localize, localize_input, iter_format_modules, get_format_modules)
|
||||
from django.utils.importlib import import_module
|
||||
@@ -28,6 +29,13 @@ from test_warnings import DeprecationWarningTests
|
||||
|
||||
class TranslationTests(TestCase):
|
||||
|
||||
def test_override(self):
|
||||
activate('de')
|
||||
with translation.override('pl'):
|
||||
self.assertEqual(get_language(), 'pl')
|
||||
self.assertEqual(get_language(), 'de')
|
||||
deactivate()
|
||||
|
||||
def test_lazy_objects(self):
|
||||
"""
|
||||
Format string interpolation should work with *_lazy objects.
|
||||
|
||||
Reference in New Issue
Block a user