From 63ef3bd05a67be9955a6c3d86c84d7a9e7d92e5d Mon Sep 17 00:00:00 2001 From: louyihua Date: Mon, 26 May 2014 15:30:01 +0800 Subject: [PATCH] i18n: More extractable & localizable strings in xmodules --- .../lib/xmodule/xmodule/annotatable_module.py | 2 +- .../xmodule/combined_open_ended_module.py | 2 +- common/lib/xmodule/xmodule/html_module.py | 6 +++--- .../xmodule/xmodule/imageannotation_module.py | 21 +++++++++++-------- .../xmodule/xmodule/peer_grading_module.py | 2 +- .../xmodule/xmodule/textannotation_module.py | 2 +- .../xmodule/xmodule/videoannotation_module.py | 2 +- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/common/lib/xmodule/xmodule/annotatable_module.py b/common/lib/xmodule/xmodule/annotatable_module.py index af344dbfa5..471b00bc8c 100644 --- a/common/lib/xmodule/xmodule/annotatable_module.py +++ b/common/lib/xmodule/xmodule/annotatable_module.py @@ -38,7 +38,7 @@ class AnnotatableFields(object): display_name=_("Display Name"), help=_("Display name for this module"), scope=Scope.settings, - default='Annotation', + default=_('Annotation'), ) diff --git a/common/lib/xmodule/xmodule/combined_open_ended_module.py b/common/lib/xmodule/xmodule/combined_open_ended_module.py index 85d4e03718..ee48c8cbe7 100644 --- a/common/lib/xmodule/xmodule/combined_open_ended_module.py +++ b/common/lib/xmodule/xmodule/combined_open_ended_module.py @@ -195,7 +195,7 @@ class CombinedOpenEndedFields(object): display_name = String( display_name=_("Display Name"), help=_("This name appears in the horizontal navigation at the top of the page."), - default="Open Response Assessment", + default=_("Open Response Assessment"), scope=Scope.settings ) current_task_number = Integer( diff --git a/common/lib/xmodule/xmodule/html_module.py b/common/lib/xmodule/xmodule/html_module.py index d2fd4cdcff..36167b971f 100644 --- a/common/lib/xmodule/xmodule/html_module.py +++ b/common/lib/xmodule/xmodule/html_module.py @@ -30,7 +30,7 @@ class HtmlFields(object): scope=Scope.settings, # it'd be nice to have a useful default but it screws up other things; so, # use display_name_with_default for those - default="Text" + default=_("Text") ) data = String(help=_("Html contents to display for this module"), default=u"", scope=Scope.content) source_code = String(help=_("Source code for LaTeX documents. This feature is not well-supported."), scope=Scope.settings) @@ -44,8 +44,8 @@ class HtmlFields(object): display_name=_("Editor"), default="visual", values=[ - {"display_name": "Visual", "value": "visual"}, - {"display_name": "Raw", "value": "raw"} + {"display_name": _("Visual"), "value": "visual"}, + {"display_name": _("Raw"), "value": "raw"} ], scope=Scope.settings ) diff --git a/common/lib/xmodule/xmodule/imageannotation_module.py b/common/lib/xmodule/xmodule/imageannotation_module.py index 9d5ab94083..e5a3306f7c 100644 --- a/common/lib/xmodule/xmodule/imageannotation_module.py +++ b/common/lib/xmodule/xmodule/imageannotation_module.py @@ -12,6 +12,9 @@ from xmodule.annotator_token import retrieve_token import textwrap +# Make '_' a no-op so we can scrape strings +_ = lambda text: text + class AnnotatableFields(object): """ Fields for `ImageModule` and `ImageDescriptor`. """ @@ -36,28 +39,28 @@ class AnnotatableFields(object): """)) display_name = String( - display_name="Display Name", - help="Display name for this module", + display_name=_("Display Name"), + help=_("Display name for this module"), scope=Scope.settings, - default='Image Annotation', + default=_('Image Annotation'), ) instructor_tags = String( - display_name="Tags for Assignments", - help="Add tags that automatically highlight in a certain color using the comma-separated form, i.e. imagery:red,parallelism:blue", + display_name=_("Tags for Assignments"), + help=_("Add tags that automatically highlight in a certain color using the comma-separated form, i.e. imagery:red,parallelism:blue"), scope=Scope.settings, default='professor:green,teachingAssistant:blue', ) annotation_storage_url = String( - help="Location of Annotation backend", + help=_("Location of Annotation backend"), scope=Scope.settings, default="http://your_annotation_storage.com", - display_name="Url for Annotation Storage" + display_name=_("Url for Annotation Storage") ) annotation_token_secret = String( - help="Secret string for annotation storage", + help=_("Secret string for annotation storage"), scope=Scope.settings, default="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", - display_name="Secret Token String for Annotation" + display_name=_("Secret Token String for Annotation") ) diff --git a/common/lib/xmodule/xmodule/peer_grading_module.py b/common/lib/xmodule/xmodule/peer_grading_module.py index 3b4e741f47..0c6ab792c1 100644 --- a/common/lib/xmodule/xmodule/peer_grading_module.py +++ b/common/lib/xmodule/xmodule/peer_grading_module.py @@ -78,7 +78,7 @@ class PeerGradingFields(object): display_name=_("Display Name"), help=_("Display name for this module"), scope=Scope.settings, - default="Peer Grading Interface" + default=_("Peer Grading Interface") ) data = String( help=_("Html contents to display for this module"), diff --git a/common/lib/xmodule/xmodule/textannotation_module.py b/common/lib/xmodule/xmodule/textannotation_module.py index 258f270787..9468f7e58f 100644 --- a/common/lib/xmodule/xmodule/textannotation_module.py +++ b/common/lib/xmodule/xmodule/textannotation_module.py @@ -33,7 +33,7 @@ class AnnotatableFields(object): display_name=_("Display Name"), help=_("Display name for this module"), scope=Scope.settings, - default='Text Annotation', + default=_('Text Annotation'), ) instructor_tags = String( display_name=_("Tags for Assignments"), diff --git a/common/lib/xmodule/xmodule/videoannotation_module.py b/common/lib/xmodule/xmodule/videoannotation_module.py index f5bd7d3e93..564d19b182 100644 --- a/common/lib/xmodule/xmodule/videoannotation_module.py +++ b/common/lib/xmodule/xmodule/videoannotation_module.py @@ -31,7 +31,7 @@ class AnnotatableFields(object): display_name=_("Display Name"), help=_("Display name for this module"), scope=Scope.settings, - default='Video Annotation', + default=_('Video Annotation'), ) sourceurl = String(help=_("The external source URL for the video."), display_name=_("Source URL"), scope=Scope.settings, default="http://video-js.zencoder.com/oceans-clip.mp4") poster_url = String(help=_("Poster Image URL"), display_name=_("Poster URL"), scope=Scope.settings, default="")