diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index b78e2a4a5019..e4a2ada3746e 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -22,7 +22,6 @@ from xblock.fields import Scope, String, Boolean, Dict, Integer, Float from .fields import Timedelta, Date from django.utils.timezone import UTC -from django.utils.translation import ugettext as _ log = logging.getLogger("edx.courseware") @@ -359,6 +358,7 @@ def check_button_name(self): """ # The logic flow is a little odd so that _('xxx') strings can be found for # translation while also running _() just once for each string. + _ = self.runtime.service(self, "i18n").ugettext check = _('Check') final_check = _('Final Check') diff --git a/common/lib/xmodule/xmodule/video_module.py b/common/lib/xmodule/xmodule/video_module.py index c5492db60139..02c458b3a552 100644 --- a/common/lib/xmodule/xmodule/video_module.py +++ b/common/lib/xmodule/xmodule/video_module.py @@ -21,7 +21,6 @@ from django.http import Http404 from django.conf import settings -from django.utils.translation import ugettext as _ from xmodule.x_module import XModule from xmodule.editing_module import TabsEditingDescriptor @@ -302,6 +301,7 @@ def get_youtube_link(video_id): else: return '' + _ = self.runtime.service(self, "i18n").ugettext video_url.update({ 'help': _('A YouTube URL or a link to a file hosted anywhere on the web.'), 'display_name': 'Video URL', diff --git a/common/lib/xmodule/xmodule/x_module.py b/common/lib/xmodule/xmodule/x_module.py index ef994bea7286..bf5fb18d6624 100644 --- a/common/lib/xmodule/xmodule/x_module.py +++ b/common/lib/xmodule/xmodule/x_module.py @@ -362,6 +362,7 @@ def __delete__(self, instance): module_runtime_attr = partial(ProxyAttribute, 'xmodule_runtime') # pylint: disable=invalid-name +@XBlock.needs("i18n") class XModule(XModuleMixin, HTMLSnippet, XBlock): # pylint: disable=abstract-method """ Implements a generic learning module. @@ -563,6 +564,7 @@ def get_template(cls, template_id): return None +@XBlock.needs("i18n") class XModuleDescriptor(XModuleMixin, HTMLSnippet, ResourceTemplates, XBlock): """ An XModuleDescriptor is a specification for an element of a course. This diff --git a/lms/djangoapps/courseware/module_render.py b/lms/djangoapps/courseware/module_render.py index 92d4ad7f02c7..5b8168d2043d 100644 --- a/lms/djangoapps/courseware/module_render.py +++ b/lms/djangoapps/courseware/module_render.py @@ -12,8 +12,8 @@ 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 publish(event, custom_user=None): 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 diff --git a/requirements/edx/github.txt b/requirements/edx/github.txt index a27eaa05ad6d..d9fca2300e98 100644 --- a/requirements/edx/github.txt +++ b/requirements/edx/github.txt @@ -15,7 +15,7 @@ -e git+https://github.com/eventbrite/zendesk.git@d53fe0e81b623f084e91776bcf6369f8b7b63879#egg=zendesk # Our libraries: --e git+https://github.com/edx/XBlock.git@fa88607#egg=XBlock +-e git+https://github.com/edx/XBlock.git@2a1efc8a413cc140d48f33fa839143ffcbd21d83#egg=XBlock -e git+https://github.com/edx/codejail.git@e3d98f9455#egg=codejail -e git+https://github.com/edx/diff-cover.git@v0.2.6#egg=diff_cover -e git+https://github.com/edx/js-test-tool.git@v0.1.5#egg=js_test_tool