From adc6929b4582b309adb906abadb30feca23c6143 Mon Sep 17 00:00:00 2001
From: louyihua
Date: Wed, 8 Apr 2015 00:47:47 +0800
Subject: [PATCH] Better i18n extraction and translation
1. Extract the full sentence rather than parital of a sentence, so that languages with different word orders than English can benifit from this.
2. Using ngettext instead of gettext with 'xxx(s)', as Transifex treats `()` as special characters so that it enforces the translated string must have the same number of `()` pairs. Such enforcement makes translations difficult, as not every language can use forms like 'xxx(s)' to represent both singular & plural within a single word.
---
cms/templates/js/staff-lock-editor.underscore | 2 +-
cms/templates/js/validation-error-modal.underscore | 6 +++++-
cms/templates/settings.html | 2 +-
3 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/cms/templates/js/staff-lock-editor.underscore b/cms/templates/js/staff-lock-editor.underscore
index 7dd07670d3..eee41c6a4f 100644
--- a/cms/templates/js/staff-lock-editor.underscore
+++ b/cms/templates/js/staff-lock-editor.underscore
@@ -15,7 +15,7 @@
<% if (xblockInfo.isVertical()) { %>
<%= gettext('If the unit was previously published and released to students, any changes you made to the unit when it was hidden will now be visible to students.') %>
<% } else { %>
- <% var message = gettext('If you make this %(xblockType)s visible to students, students will be able to see its content after the release date has passed and you have published the unit(s).'); %>
+ <% var message = gettext('If you make this %(xblockType)s visible to students, students will be able to see its content after the release date has passed and you have published the unit.'); %>
<%= interpolate(message, { xblockType: xblockType }, true) %>
<% } %>
<%= _.template(
- gettext("There were {strong_start}{num_errors} validation error(s){strong_end} while trying to save the course setting(s) in the database."),
+ ngettext(
+ "There was {strong_start}{num_errors} validation error{strong_end} while trying to save the course settings in the database.",
+ "There were {strong_start}{num_errors} validation errors{strong_end} while trying to save the course settings in the database.",
+ num_errors
+ ),
{
strong_start:'',
num_errors: num_errors,
diff --git a/cms/templates/settings.html b/cms/templates/settings.html
index ad78d9eb22..a07debb683 100644
--- a/cms/templates/settings.html
+++ b/cms/templates/settings.html
@@ -319,7 +319,7 @@ CMS.URL.UPLOAD_ASSET = '${upload_asset_url}';
-
${_("You can now view and author your course entrance exam from the ")}${_("Course Outline")}
+
${_("You can now view and author your course entrance exam from the {link_start}Course Outline{link_end}.").format(link_start="".format(course_handler_url), link_end="")}
${_("Grade Requirements")}
${_(" %")}
${_("The score student must meet in order to successfully complete the entrance exam. ")}