XBlock fields with formatted-in values can now translate properly
This commit is contained in:
@@ -140,10 +140,16 @@ class CourseMetadata(object):
|
||||
for field in descriptor.fields.values():
|
||||
if field.scope != Scope.settings:
|
||||
continue
|
||||
|
||||
field_help = _(field.help) # pylint: disable=translation-of-non-string
|
||||
help_args = field.runtime_options.get('help_format_args')
|
||||
if help_args is not None:
|
||||
field_help = field_help.format(**help_args)
|
||||
|
||||
result[field.name] = {
|
||||
'value': field.read_json(descriptor),
|
||||
'display_name': _(field.display_name), # pylint: disable=translation-of-non-string
|
||||
'help': _(field.help), # pylint: disable=translation-of-non-string
|
||||
'help': field_help,
|
||||
'deprecated': field.runtime_options.get('deprecated', False)
|
||||
}
|
||||
return result
|
||||
|
||||
@@ -732,7 +732,8 @@ class CourseFields(object):
|
||||
'For example, to specify that teams should have a maximum of 5 participants and provide a list of '
|
||||
'2 topics, enter the configuration in this format: {example_format}. '
|
||||
'In "id" values, the only supported special characters are underscore, hyphen, and period.'
|
||||
).format(
|
||||
),
|
||||
help_format_args=dict(
|
||||
# Put the sample JSON into a format variable so that translators
|
||||
# don't muck with it.
|
||||
example_format=(
|
||||
|
||||
@@ -178,7 +178,8 @@ class InheritanceMixin(XBlockMixin):
|
||||
"Identify a video, 5-10 seconds in length, to play before course videos. Enter the video ID from "
|
||||
"the Video Uploads page and one or more transcript files in the following format: {format}. "
|
||||
"For example, an entry for a video with two transcripts looks like this: {example}"
|
||||
).format(
|
||||
),
|
||||
help_format_args=dict(
|
||||
format='{"video_id": "ID", "transcripts": {"language": "/static/filename.srt"}}',
|
||||
example=(
|
||||
'{'
|
||||
|
||||
Reference in New Issue
Block a user