diff --git a/django/core/serializers/json.py b/django/core/serializers/json.py
index 27c7c30..d7e5b15 100644
a
|
b
|
from django.core.serializers.python import Serializer as PythonSerializer
|
9 | 9 | from django.core.serializers.python import Deserializer as PythonDeserializer |
10 | 10 | from django.utils import datetime_safe |
11 | 11 | from django.utils import simplejson |
| 12 | from django.utils.functional import Promise |
12 | 13 | |
13 | 14 | try: |
14 | 15 | import decimal |
… |
… |
class DjangoJSONEncoder(simplejson.JSONEncoder):
|
61 | 62 | return o.strftime(self.TIME_FORMAT) |
62 | 63 | elif isinstance(o, decimal.Decimal): |
63 | 64 | return str(o) |
| 65 | elif isinstance(o, Promise): |
| 66 | # The input is the result of a gettext_lazy() call. |
| 67 | return unicode(o).encode('utf-8', 'strict') |
64 | 68 | else: |
65 | 69 | return super(DjangoJSONEncoder, self).default(o) |
66 | 70 | |
diff --git a/tests/regressiontests/i18n/tests.py b/tests/regressiontests/i18n/tests.py
index c2a39cd..fae061e 100644
a
|
b
|
class TranslationTests(TestCase):
|
39 | 39 | self.assertEqual(True, s == s2) |
40 | 40 | s4 = ugettext_lazy('Some other string') |
41 | 41 | self.assertEqual(False, s == s4) |
| 42 | |
| 43 | #it should be possible to serialize *_lazy objects. |
| 44 | from django.core.serializers import json |
| 45 | from django.utils import simplejson |
| 46 | serialized = simplejson.dumps(ugettext_lazy('Yet another string'), |
| 47 | cls=json.DjangoJSONEncoder) |
| 48 | self.assertEqual('"Yet another string"', serialized) |
42 | 49 | |
43 | 50 | def test_string_concat(self): |
44 | 51 | """ |