diff --git a/django/views/i18n.py b/django/views/i18n.py index 89963e8406..3bd240ea3d 100644 --- a/django/views/i18n.py +++ b/django/views/i18n.py @@ -284,7 +284,7 @@ class JavaScriptCatalog(View): ) if context['catalog'] else None context['formats_str'] = indent(json.dumps(context['formats'], sort_keys=True, indent=2)) - return HttpResponse(template.render(Context(context)), 'text/javascript') + return HttpResponse(template.render(Context(context)), 'text/javascript; charset="utf-8"') class JSONCatalog(JavaScriptCatalog): diff --git a/tests/view_tests/tests/test_i18n.py b/tests/view_tests/tests/test_i18n.py index 125d6e0a5f..5baa755580 100644 --- a/tests/view_tests/tests/test_i18n.py +++ b/tests/view_tests/tests/test_i18n.py @@ -206,6 +206,7 @@ class I18NViewTests(SimpleTestCase): catalog = gettext.translation('djangojs', locale_dir, [lang_code]) trans_txt = catalog.gettext('this is to be translated') response = self.client.get('/jsi18n/') + self.assertEqual(response['Content-Type'], 'text/javascript; charset="utf-8"') # response content must include a line like: # "this is to be translated": # json.dumps() is used to be able to check unicode strings