From d138a2c6be039a2872c84b500fea421307e5d3fd Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Thu, 9 Jan 2014 13:30:39 -0500 Subject: [PATCH] Use Django for runtime i18n The django.utils.translation module has the right interface to serve as a gettext.Translations object, so we use it for the runtime i18n service. LMS-1597 --- lms/djangoapps/courseware/module_render.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 92d4ad7f02..5b8168d204 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -12,8 +12,8 @@ from django.contrib.auth.models import User from django.core.cache import cache from django.core.exceptions import PermissionDenied from django.core.urlresolvers import reverse -from django.http import Http404 -from django.http import HttpResponse +from django.http import Http404, HttpResponse +import django.utils from django.views.decorators.csrf import csrf_exempt, csrf_protect from capa.xqueue_interface import XQueueInterface @@ -419,6 +419,12 @@ def get_module_for_descriptor_internal(user, descriptor, field_data_cache, cours mixins=descriptor.runtime.mixologist._mixins, # pylint: disable=protected-access wrappers=block_wrappers, get_real_user=user_by_anonymous_id, + services={ + # django.utils.translation implements the gettext.Translations + # interface (it has ugettext, ungettext, etc), so we can use it + # directly as the runtime i18n service. + 'i18n': django.utils.translation, + }, ) # pass position specified in URL to module through ModuleSystem