Commit cf6a83f4 by Ned Batchelder

Merge pull request #3730 from louyihua/localization-fix-video

i18n: Make translation works for video editor tabs
parents 01609279 dba66c2a
......@@ -44,6 +44,7 @@ def get_ext(filename):
log = logging.getLogger(__name__)
_ = lambda text: text
class VideoModule(VideoFields, VideoStudentViewHandlers, XModule):
......@@ -177,12 +178,12 @@ class VideoDescriptor(VideoFields, VideoStudioViewHandlers, TabsEditingDescripto
tabs = [
{
'name': "Basic",
'name': _("Basic"),
'template': "video/transcripts.html",
'current': True
},
{
'name': "Advanced",
'name': _("Advanced"),
'template': "tabs/metadata-edit-tab.html"
}
]
......@@ -358,7 +359,7 @@ class VideoDescriptor(VideoFields, VideoStudioViewHandlers, TabsEditingDescripto
_ = self.runtime.service(self, "i18n").ugettext
video_url.update({
'help': _('The URL for your video. This can be a YouTube URL or a link to an .mp4, .ogg, or .webm video file hosted elsewhere on the Internet.'),
'display_name': 'Default Video URL',
'display_name': _('Default Video URL'),
'field_name': 'video_url',
'type': 'VideoList',
'default_value': [get_youtube_link(youtube_id_1_0['default_value'])]
......
......@@ -778,6 +778,13 @@ class XModuleDescriptor(XModuleMixin, HTMLSnippet, ResourceTemplates, XBlock):
json_choice = field.to_json(json_choice)
return json_choice
def get_text(value):
"""Localize a text value that might be None."""
if value is None:
return None
else:
return self.runtime.service(self, "i18n").ugettext(value)
metadata_fields = {}
# Only use the fields from this class, not mixins
......@@ -791,8 +798,8 @@ class XModuleDescriptor(XModuleMixin, HTMLSnippet, ResourceTemplates, XBlock):
# gets the 'default_value' and 'explicitly_set' attrs
metadata_fields[field.name] = self.runtime.get_field_provenance(self, field)
metadata_fields[field.name]['field_name'] = field.name
metadata_fields[field.name]['display_name'] = field.display_name
metadata_fields[field.name]['help'] = field.help
metadata_fields[field.name]['display_name'] = get_text(field.display_name)
metadata_fields[field.name]['help'] = get_text(field.help)
metadata_fields[field.name]['value'] = field.read_json(self)
# We support the following editors:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment