Merge pull request #3802 from louyihua/translation-fix
i18n: Make checklists translatable
This commit is contained in:
@@ -16,6 +16,8 @@ from .access import has_course_access
|
||||
from xmodule.course_module import CourseDescriptor
|
||||
from xmodule.modulestore.locator import BlockUsageLocator
|
||||
|
||||
from django.utils.translation import ugettext
|
||||
|
||||
__all__ = ['checklists_handler']
|
||||
|
||||
|
||||
@@ -79,7 +81,7 @@ def checklists_handler(request, tag=None, package_id=None, branch=None, version_
|
||||
course_module.save()
|
||||
modulestore.update_item(course_module, request.user.id)
|
||||
expanded_checklist = expand_checklist_action_url(course_module, persisted_checklist)
|
||||
return JsonResponse(expanded_checklist)
|
||||
return JsonResponse(localize_checklist_text(expanded_checklist))
|
||||
else:
|
||||
return HttpResponseBadRequest(
|
||||
("Could not save checklist state because the checklist index "
|
||||
@@ -99,7 +101,7 @@ def expand_all_action_urls(course_module):
|
||||
"""
|
||||
expanded_checklists = []
|
||||
for checklist in course_module.checklists:
|
||||
expanded_checklists.append(expand_checklist_action_url(course_module, checklist))
|
||||
expanded_checklists.append(localize_checklist_text(expand_checklist_action_url(course_module, checklist)))
|
||||
return expanded_checklists
|
||||
|
||||
|
||||
@@ -127,3 +129,20 @@ def expand_checklist_action_url(course_module, checklist):
|
||||
item['action_url'] = location.url_reverse(url_prefix, '')
|
||||
|
||||
return expanded_checklist
|
||||
|
||||
def localize_checklist_text(checklist):
|
||||
"""
|
||||
Localize texts for a given checklist and returns the modified version.
|
||||
|
||||
The method does an in-place operation so the input checklist is modified directly.
|
||||
"""
|
||||
# Localize checklist name
|
||||
checklist['short_description'] = ugettext(checklist['short_description'])
|
||||
|
||||
# Localize checklist items
|
||||
for item in checklist.get('items'):
|
||||
item['short_description'] = ugettext(item['short_description'])
|
||||
item['long_description'] = ugettext(item['long_description'])
|
||||
item['action_text'] = ugettext(item['action_text']) if item['action_text'] != "" else u""
|
||||
|
||||
return checklist
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext as _
|
||||
%>
|
||||
<%block name="title">Course Checklists</%block>
|
||||
<%block name="title">${_("Course Checklists")}</%block>
|
||||
<%block name="bodyclass">is-signedin course view-checklists</%block>
|
||||
|
||||
<%namespace name='static' file='static_content.html'/>
|
||||
@@ -64,7 +64,7 @@ require(["domReady!", "jquery", "js/collections/checklist", "js/views/checklist"
|
||||
</div>
|
||||
|
||||
<div class="bit">
|
||||
<h3 class="title title-3">Studio checklists</h3>
|
||||
<h3 class="title title-3">${_("Studio checklists")}</h3>
|
||||
<nav class="nav-page checklists-current">
|
||||
<ol>
|
||||
% for checklist in checklists:
|
||||
|
||||
@@ -22,6 +22,9 @@ from django.utils.timezone import UTC
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
# Make '_' a no-op so we can scrape strings
|
||||
_ = lambda text: text
|
||||
|
||||
|
||||
class StringOrDate(Date):
|
||||
def from_json(self, value):
|
||||
@@ -223,7 +226,7 @@ class CourseFields(object):
|
||||
}},
|
||||
scope=Scope.content)
|
||||
show_calculator = Boolean(help="Whether to show the calculator in this course", default=False, scope=Scope.settings)
|
||||
display_name = String(help="Display name for this module", default="Empty", display_name="Display Name", scope=Scope.settings)
|
||||
display_name = String(help="Display name for this module", default="Empty", display_name=_("Display Name"), scope=Scope.settings)
|
||||
course_edit_method = String(help="Method with which this course is edited.", default="Studio", scope=Scope.settings)
|
||||
show_chat = Boolean(help="Whether to show the chat widget in this course", default=False, scope=Scope.settings)
|
||||
tabs = CourseTabList(help="List of tabs to enable in this course", scope=Scope.settings, default=[])
|
||||
@@ -245,117 +248,117 @@ class CourseFields(object):
|
||||
has_children = True
|
||||
checklists = List(scope=Scope.settings,
|
||||
default=[
|
||||
{"short_description": "Getting Started With Studio",
|
||||
"items": [{"short_description": "Add Course Team Members",
|
||||
"long_description": "Grant your collaborators permission to edit your course so you can work together.",
|
||||
{"short_description": _("Getting Started With Studio"),
|
||||
"items": [{"short_description": _("Add Course Team Members"),
|
||||
"long_description": _("Grant your collaborators permission to edit your course so you can work together."),
|
||||
"is_checked": False,
|
||||
"action_url": "ManageUsers",
|
||||
"action_text": "Edit Course Team",
|
||||
"action_text": _("Edit Course Team"),
|
||||
"action_external": False},
|
||||
{"short_description": "Set Important Dates for Your Course",
|
||||
"long_description": "Establish your course's student enrollment and launch dates on the Schedule and Details page.",
|
||||
{"short_description": _("Set Important Dates for Your Course"),
|
||||
"long_description": _("Establish your course's student enrollment and launch dates on the Schedule and Details page."),
|
||||
"is_checked": False,
|
||||
"action_url": "SettingsDetails",
|
||||
"action_text": "Edit Course Details & Schedule",
|
||||
"action_text": _("Edit Course Details & Schedule"),
|
||||
"action_external": False},
|
||||
{"short_description": "Draft Your Course's Grading Policy",
|
||||
"long_description": "Set up your assignment types and grading policy even if you haven't created all your assignments.",
|
||||
{"short_description": _("Draft Your Course's Grading Policy"),
|
||||
"long_description": _("Set up your assignment types and grading policy even if you haven't created all your assignments."),
|
||||
"is_checked": False,
|
||||
"action_url": "SettingsGrading",
|
||||
"action_text": "Edit Grading Settings",
|
||||
"action_text": _("Edit Grading Settings"),
|
||||
"action_external": False},
|
||||
{"short_description": "Explore the Other Studio Checklists",
|
||||
"long_description": "Discover other available course authoring tools, and find help when you need it.",
|
||||
{"short_description": _("Explore the Other Studio Checklists"),
|
||||
"long_description": _("Discover other available course authoring tools, and find help when you need it."),
|
||||
"is_checked": False,
|
||||
"action_url": "",
|
||||
"action_text": "",
|
||||
"action_external": False}]},
|
||||
{"short_description": "Draft a Rough Course Outline",
|
||||
"items": [{"short_description": "Create Your First Section and Subsection",
|
||||
"long_description": "Use your course outline to build your first Section and Subsection.",
|
||||
{"short_description": _("Draft a Rough Course Outline"),
|
||||
"items": [{"short_description": _("Create Your First Section and Subsection"),
|
||||
"long_description": _("Use your course outline to build your first Section and Subsection."),
|
||||
"is_checked": False,
|
||||
"action_url": "CourseOutline",
|
||||
"action_text": "Edit Course Outline",
|
||||
"action_text": _("Edit Course Outline"),
|
||||
"action_external": False},
|
||||
{"short_description": "Set Section Release Dates",
|
||||
"long_description": "Specify the release dates for each Section in your course. Sections become visible to students on their release dates.",
|
||||
{"short_description": _("Set Section Release Dates"),
|
||||
"long_description": _("Specify the release dates for each Section in your course. Sections become visible to students on their release dates."),
|
||||
"is_checked": False,
|
||||
"action_url": "CourseOutline",
|
||||
"action_text": "Edit Course Outline",
|
||||
"action_text": _("Edit Course Outline"),
|
||||
"action_external": False},
|
||||
{"short_description": "Designate a Subsection as Graded",
|
||||
"long_description": "Set a Subsection to be graded as a specific assignment type. Assignments within graded Subsections count toward a student's final grade.",
|
||||
{"short_description": _("Designate a Subsection as Graded"),
|
||||
"long_description": _("Set a Subsection to be graded as a specific assignment type. Assignments within graded Subsections count toward a student's final grade."),
|
||||
"is_checked": False,
|
||||
"action_url": "CourseOutline",
|
||||
"action_text": "Edit Course Outline",
|
||||
"action_text": _("Edit Course Outline"),
|
||||
"action_external": False},
|
||||
{"short_description": "Reordering Course Content",
|
||||
"long_description": "Use drag and drop to reorder the content in your course.",
|
||||
{"short_description": _("Reordering Course Content"),
|
||||
"long_description": _("Use drag and drop to reorder the content in your course."),
|
||||
"is_checked": False,
|
||||
"action_url": "CourseOutline",
|
||||
"action_text": "Edit Course Outline",
|
||||
"action_text": _("Edit Course Outline"),
|
||||
"action_external": False},
|
||||
{"short_description": "Renaming Sections",
|
||||
"long_description": "Rename Sections by clicking the Section name from the Course Outline.",
|
||||
{"short_description": _("Renaming Sections"),
|
||||
"long_description": _("Rename Sections by clicking the Section name from the Course Outline."),
|
||||
"is_checked": False,
|
||||
"action_url": "CourseOutline",
|
||||
"action_text": "Edit Course Outline",
|
||||
"action_text": _("Edit Course Outline"),
|
||||
"action_external": False},
|
||||
{"short_description": "Deleting Course Content",
|
||||
"long_description": "Delete Sections, Subsections, or Units you don't need anymore. Be careful, as there is no Undo function.",
|
||||
{"short_description": _("Deleting Course Content"),
|
||||
"long_description": _("Delete Sections, Subsections, or Units you don't need anymore. Be careful, as there is no Undo function."),
|
||||
"is_checked": False,
|
||||
"action_url": "CourseOutline",
|
||||
"action_text": "Edit Course Outline",
|
||||
"action_text": _("Edit Course Outline"),
|
||||
"action_external": False},
|
||||
{"short_description": "Add an Instructor-Only Section to Your Outline",
|
||||
"long_description": "Some course authors find using a section for unsorted, in-progress work useful. To do this, create a section and set the release date to the distant future.",
|
||||
{"short_description": _("Add an Instructor-Only Section to Your Outline"),
|
||||
"long_description": _("Some course authors find using a section for unsorted, in-progress work useful. To do this, create a section and set the release date to the distant future."),
|
||||
"is_checked": False,
|
||||
"action_url": "CourseOutline",
|
||||
"action_text": "Edit Course Outline",
|
||||
"action_text": _("Edit Course Outline"),
|
||||
"action_external": False}]},
|
||||
{"short_description": "Explore edX's Support Tools",
|
||||
"items": [{"short_description": "Explore the Studio Help Forum",
|
||||
"long_description": "Access the Studio Help forum from the menu that appears when you click your user name in the top right corner of Studio.",
|
||||
{"short_description": _("Explore edX's Support Tools"),
|
||||
"items": [{"short_description": _("Explore the Studio Help Forum"),
|
||||
"long_description": _("Access the Studio Help forum from the menu that appears when you click your user name in the top right corner of Studio."),
|
||||
"is_checked": False,
|
||||
"action_url": "http://help.edge.edx.org/",
|
||||
"action_text": "Visit Studio Help",
|
||||
"action_text": _("Visit Studio Help"),
|
||||
"action_external": True},
|
||||
{"short_description": "Enroll in edX 101",
|
||||
"long_description": "Register for edX 101, edX's primer for course creation.",
|
||||
{"short_description": _("Enroll in edX 101"),
|
||||
"long_description": _("Register for edX 101, edX's primer for course creation."),
|
||||
"is_checked": False,
|
||||
"action_url": "https://edge.edx.org/courses/edX/edX101/How_to_Create_an_edX_Course/about",
|
||||
"action_text": "Register for edX 101",
|
||||
"action_text": _("Register for edX 101"),
|
||||
"action_external": True},
|
||||
{"short_description": "Download the Studio Documentation",
|
||||
"long_description": "Download the searchable Studio reference documentation in PDF form.",
|
||||
{"short_description": _("Download the Studio Documentation"),
|
||||
"long_description": _("Download the searchable Studio reference documentation in PDF form."),
|
||||
"is_checked": False,
|
||||
"action_url": "http://files.edx.org/Getting_Started_with_Studio.pdf",
|
||||
"action_text": "Download Documentation",
|
||||
"action_text": _("Download Documentation"),
|
||||
"action_external": True}]},
|
||||
{"short_description": "Draft Your Course About Page",
|
||||
"items": [{"short_description": "Draft a Course Description",
|
||||
"long_description": "Courses on edX have an About page that includes a course video, description, and more. Draft the text students will read before deciding to enroll in your course.",
|
||||
{"short_description": _("Draft Your Course About Page"),
|
||||
"items": [{"short_description": _("Draft a Course Description"),
|
||||
"long_description": _("Courses on edX have an About page that includes a course video, description, and more. Draft the text students will read before deciding to enroll in your course."),
|
||||
"is_checked": False,
|
||||
"action_url": "SettingsDetails",
|
||||
"action_text": "Edit Course Schedule & Details",
|
||||
"action_text": _("Edit Course Schedule & Details"),
|
||||
"action_external": False},
|
||||
{"short_description": "Add Staff Bios",
|
||||
"long_description": "Showing prospective students who their instructor will be is helpful. Include staff bios on the course About page.",
|
||||
{"short_description": _("Add Staff Bios"),
|
||||
"long_description": _("Showing prospective students who their instructor will be is helpful. Include staff bios on the course About page."),
|
||||
"is_checked": False,
|
||||
"action_url": "SettingsDetails",
|
||||
"action_text": "Edit Course Schedule & Details",
|
||||
"action_text": _("Edit Course Schedule & Details"),
|
||||
"action_external": False},
|
||||
{"short_description": "Add Course FAQs",
|
||||
"long_description": "Include a short list of frequently asked questions about your course.",
|
||||
{"short_description": _("Add Course FAQs"),
|
||||
"long_description": _("Include a short list of frequently asked questions about your course."),
|
||||
"is_checked": False,
|
||||
"action_url": "SettingsDetails",
|
||||
"action_text": "Edit Course Schedule & Details",
|
||||
"action_text": _("Edit Course Schedule & Details"),
|
||||
"action_external": False},
|
||||
{"short_description": "Add Course Prerequisites",
|
||||
"long_description": "Let students know what knowledge and/or skills they should have before they enroll in your course.",
|
||||
{"short_description": _("Add Course Prerequisites"),
|
||||
"long_description": _("Let students know what knowledge and/or skills they should have before they enroll in your course."),
|
||||
"is_checked": False,
|
||||
"action_url": "SettingsDetails",
|
||||
"action_text": "Edit Course Schedule & Details",
|
||||
"action_text": _("Edit Course Schedule & Details"),
|
||||
"action_external": False}]}
|
||||
])
|
||||
info_sidebar_name = String(scope=Scope.settings, default='Course Handouts')
|
||||
|
||||
Reference in New Issue
Block a user