Commit 2f8088ea by Sarina Canelake

Merge pull request #2057 from edx/ormsbee/js_gettext

Remove JS gettext() in templates
parents bccae306 ff192935
...@@ -18,13 +18,14 @@ ...@@ -18,13 +18,14 @@
<%block name="jsextra"> <%block name="jsextra">
<script type="text/javascript"> <script type="text/javascript">
require(["domReady", "jquery", "gettext", "js/models/asset", "js/collections/asset", require(["domReady", "jquery", "js/models/asset", "js/collections/asset",
"js/views/assets", "js/views/feedback_prompt", "js/views/assets", "js/views/feedback_prompt",
"js/views/feedback_notification", "js/views/paging_header", "js/views/paging_footer", "js/views/feedback_notification", "js/views/paging_header", "js/views/paging_footer",
"js/utils/modal", "jquery.fileupload"], "js/utils/modal", "jquery.fileupload"],
function(domReady, $, gettext, AssetModel, AssetCollection, AssetsView, PromptView, NotificationView, function(domReady, $, AssetModel, AssetCollection, AssetsView, PromptView, NotificationView,
PagingHeader, PagingFooter, ModalUtils) { PagingHeader, PagingFooter, ModalUtils) {
var assets = new AssetCollection(); var assets = new AssetCollection();
assets.url = "${asset_callback_url}"; assets.url = "${asset_callback_url}";
var assetsView = new AssetsView({collection: assets, el: $('#asset-library')}); var assetsView = new AssetsView({collection: assets, el: $('#asset-library')});
assetsView.render(); assetsView.render();
...@@ -74,7 +75,7 @@ require(["domReady", "jquery", "gettext", "js/models/asset", "js/collections/ass ...@@ -74,7 +75,7 @@ require(["domReady", "jquery", "gettext", "js/models/asset", "js/collections/ass
var startUpload = function (e) { var startUpload = function (e) {
var file = e.target.value; var file = e.target.value;
$('.upload-modal h1').html(gettext('Uploading…')); $('.upload-modal h1').text("${_(u'Uploading…')}");
$('.upload-modal .file-name').html(file.substring(file.lastIndexOf("\\") + 1)); $('.upload-modal .file-name').html(file.substring(file.lastIndexOf("\\") + 1));
$('.upload-modal .choose-file-button').hide(); $('.upload-modal .choose-file-button').hide();
$('.upload-modal .progress-bar').removeClass('loaded').show(); $('.upload-modal .progress-bar').removeClass('loaded').show();
...@@ -90,7 +91,7 @@ require(["domReady", "jquery", "gettext", "js/models/asset", "js/collections/ass ...@@ -90,7 +91,7 @@ require(["domReady", "jquery", "gettext", "js/models/asset", "js/collections/ass
$('.upload-modal .file-name').show(); $('.upload-modal .file-name').show();
$('.upload-modal .file-name').html(''); $('.upload-modal .file-name').html('');
$('.upload-modal .choose-file-button').html(gettext('Choose File')); $('.upload-modal .choose-file-button').text("${_('Choose File')}");
$('.upload-modal .embeddable-xml-input').val(''); $('.upload-modal .embeddable-xml-input').val('');
$('.upload-modal .embeddable').hide(); $('.upload-modal .embeddable').hide();
}; };
...@@ -104,12 +105,12 @@ require(["domReady", "jquery", "gettext", "js/models/asset", "js/collections/ass ...@@ -104,12 +105,12 @@ require(["domReady", "jquery", "gettext", "js/models/asset", "js/collections/ass
var displayFinishedUpload = function (resp) { var displayFinishedUpload = function (resp) {
var asset = resp.asset; var asset = resp.asset;
$('.upload-modal h1').html(gettext('Upload New File')); $('.upload-modal h1').text("${_('Upload New File')}");
$('.upload-modal .embeddable-xml-input').val(asset.portable_url); $('.upload-modal .embeddable-xml-input').val(asset.portable_url);
$('.upload-modal .embeddable').show(); $('.upload-modal .embeddable').show();
$('.upload-modal .file-name').hide(); $('.upload-modal .file-name').hide();
$('.upload-modal .progress-fill').html(resp.msg); $('.upload-modal .progress-fill').html(resp.msg);
$('.upload-modal .choose-file-button').html(gettext('Load Another File')).show(); $('.upload-modal .choose-file-button').text("${_('Load Another File')}").show();
$('.upload-modal .progress-fill').width('100%'); $('.upload-modal .progress-fill').width('100%');
assetsView.addAsset(new AssetModel(asset)); assetsView.addAsset(new AssetModel(asset));
......
...@@ -34,7 +34,7 @@ require(["js/models/section", "js/collections/textbook", "js/views/list_textbook ...@@ -34,7 +34,7 @@ require(["js/models/section", "js/collections/textbook", "js/views/list_textbook
$(window).on("beforeunload", function() { $(window).on("beforeunload", function() {
var dirty = textbooks.find(function(textbook) { return textbook.isDirty(); }); var dirty = textbooks.find(function(textbook) { return textbook.isDirty(); });
if(dirty) { if(dirty) {
return gettext("You have unsaved changes. Do you really want to leave this page?"); return "${_('You have unsaved changes. Do you really want to leave this page?')}";
} }
}) })
}) })
......
...@@ -144,7 +144,7 @@ FEATURES = { ...@@ -144,7 +144,7 @@ FEATURES = {
# Enables the student notes API and UI. # Enables the student notes API and UI.
'ENABLE_STUDENT_NOTES': True, 'ENABLE_STUDENT_NOTES': True,
# Provide a UI to allow users to submit feedback from the LMS # Provide a UI to allow users to submit feedback from the LMS (left-hand help modal)
'ENABLE_FEEDBACK_SUBMISSION': False, 'ENABLE_FEEDBACK_SUBMISSION': False,
# Turn on a page that lets staff enter Python code to be run in the # Turn on a page that lets staff enter Python code to be run in the
......
...@@ -60,14 +60,14 @@ discussion_link = get_discussion_link(course) if course else None ...@@ -60,14 +60,14 @@ discussion_link = get_discussion_link(course) if course else None
<form id="feedback_form" class="feedback_form" method="post" data-remote="true" action="/submit_feedback"> <form id="feedback_form" class="feedback_form" method="post" data-remote="true" action="/submit_feedback">
<div id="feedback_error" class="modal-form-error" tabindex="-1"></div> <div id="feedback_error" class="modal-form-error" tabindex="-1"></div>
% if not user.is_authenticated(): % if not user.is_authenticated():
<label data-field="name" for="feedback_form_name">${_('Name*')}</label> <label data-field="name" for="feedback_form_name">${_('Name')}*</label>
<input name="name" type="text" id="feedback_form_name" aria-required="true"> <input name="name" type="text" id="feedback_form_name" aria-required="true">
<label data-field="email" for="feedback_form_email">${_('E-mail*')}</label> <label data-field="email" for="feedback_form_email">${_('E-mail')}*</label>
<input name="email" type="text" id="feedback_form_email" aria-required="true"> <input name="email" type="text" id="feedback_form_email" aria-required="true">
% endif % endif
<label data-field="subject" for="feedback_form_subject">${_('Briefly describe your issue*')}</label> <label data-field="subject" for="feedback_form_subject">${_('Briefly describe your issue')}*</label>
<input name="subject" type="text" id="feedback_form_subject" aria-required="true"> <input name="subject" type="text" id="feedback_form_subject" aria-required="true">
<label data-field="details" for="feedback_form_details">${_('Tell us the details*')} <label data-field="details" for="feedback_form_details">${_('Tell us the details')}*
<span class="tip">${_('Include error messages, steps which lead to the issue, etc')}</span></label> <span class="tip">${_('Include error messages, steps which lead to the issue, etc')}</span></label>
<textarea name="details" id="feedback_form_details" aria-required="true"></textarea> <textarea name="details" id="feedback_form_details" aria-required="true"></textarea>
<input name="issue_type" type="hidden"> <input name="issue_type" type="hidden">
...@@ -75,7 +75,7 @@ discussion_link = get_discussion_link(course) if course else None ...@@ -75,7 +75,7 @@ discussion_link = get_discussion_link(course) if course else None
<input name="course_id" type="hidden" value="${course.id | h}"> <input name="course_id" type="hidden" value="${course.id | h}">
% endif % endif
<div class="submit"> <div class="submit">
<input name="submit" type="submit" value="Submit" id="feedback_submit"> <input name="submit" type="submit" value="${_('Submit')}" id="feedback_submit">
</div> </div>
</form> </form>
</div> </div>
...@@ -168,29 +168,29 @@ discussion_link = get_discussion_link(course) if course else None ...@@ -168,29 +168,29 @@ discussion_link = get_discussion_link(course) if course else None
$("#feedback_link_problem").click(function(event) { $("#feedback_link_problem").click(function(event) {
showFeedback( showFeedback(
event, event,
gettext("problem"), "${_('problem')}",
gettext("Report a Problem"), "${_('Report a Problem')}",
gettext("Brief description of the problem*"), "${_('Brief description of the problem')}" + "*",
gettext("Details of the problem you are encountering*") + "<span class='tip'>" + "${_('Details of the problem you are encountering')}" + "*" + "<span class='tip'>" +
gettext("Include error messages, steps which lead to the issue, etc.") + "</span>" "${_('Include error messages, steps which lead to the issue, etc.')}" + "</span>"
); );
}); });
$("#feedback_link_suggestion").click(function(event) { $("#feedback_link_suggestion").click(function(event) {
showFeedback( showFeedback(
event, event,
gettext("suggestion"), "${_('suggestion')}",
gettext("Make a Suggestion"), "${_('Make a Suggestion')}",
gettext("Brief description of your suggestion*"), "${_('Brief description of your suggestion')}" + "*",
gettext("Details*") "${_('Details')}" + "*"
); );
}); });
$("#feedback_link_question").click(function(event) { $("#feedback_link_question").click(function(event) {
showFeedback( showFeedback(
event, event,
gettext("question"), "${_('question')}",
gettext("Ask a Question"), "${_('Ask a Question')}",
gettext("Brief summary of your question*"), "${_('Brief summary of your question')}" + "*",
gettext("Details*") "${_('Details')}" + "*"
); );
}); });
$("#feedback_form").submit(function() { $("#feedback_form").submit(function() {
...@@ -218,16 +218,16 @@ discussion_link = get_discussion_link(course) if course else None ...@@ -218,16 +218,16 @@ discussion_link = get_discussion_link(course) if course else None
$("#feedback_error").html(responseData.error).stop().css("display", "block"); $("#feedback_error").html(responseData.error).stop().css("display", "block");
} else { } else {
// If no data (or malformed data) is returned, a server error occurred // If no data (or malformed data) is returned, a server error occurred
htmlStr = gettext("An error has occurred."); htmlStr = "${_('An error has occurred.')}";
% if settings.FEEDBACK_SUBMISSION_EMAIL: % if settings.FEEDBACK_SUBMISSION_EMAIL:
htmlStr += " " + _.template( htmlStr += " " + _.template(
gettext("Please {link_start}send us e-mail{link_end}."), "${_('Please {link_start}send us e-mail{link_end}.')}",
{link_start: '<a href="#" id="feedback_email">', link_end: '</a>'}, {link_start: '<a href="#" id="feedback_email">', link_end: '</a>'},
{interpolate: /\{(.+?)\}/g}) {interpolate: /\{(.+?)\}/g})
% else: % else:
// If no email is configured, we can't do much other than // If no email is configured, we can't do much other than
// ask the user to try again later // ask the user to try again later
htmlStr += gettext(" Please try again later."); htmlStr += "${_('Please try again later.')}";
% endif % endif
$("#feedback_error").html(htmlStr).stop().css("display", "block"); $("#feedback_error").html(htmlStr).stop().css("display", "block");
% if settings.FEEDBACK_SUBMISSION_EMAIL: % if settings.FEEDBACK_SUBMISSION_EMAIL:
......
...@@ -89,7 +89,7 @@ ...@@ -89,7 +89,7 @@
$submitButton. $submitButton.
addClass('is-disabled'). addClass('is-disabled').
prop('disabled', true). prop('disabled', true).
html("${_(u'Processing your account information…')}"); text("${_(u'Processing your account information…')}");
} }
} }
</script> </script>
......
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
$(function() { $(function() {
var form = $("#disable-form"); var form = $("#disable-form");
$("#submit-form").click(function(){ $("#submit-form").click(function(){
$("#account-change-status").html(gettext("working...")); $("#account-change-status").text("${_('working...')}");
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: form.attr('action'), url: form.attr('action'),
......
...@@ -70,13 +70,13 @@ ...@@ -70,13 +70,13 @@
$submitButton. $submitButton.
removeClass('is-disabled'). removeClass('is-disabled').
removeProp('disabled'). removeProp('disabled').
html("${_('Update my {platform_name} Account').format(platform_name=settings.PLATFORM_NAME)}"); text("${_('Update my {platform_name} Account').format(platform_name=settings.PLATFORM_NAME)}");
} }
else { else {
$submitButton. $submitButton.
addClass('is-disabled'). addClass('is-disabled').
prop('disabled', true). prop('disabled', true).
html(gettext('Processing your account information &hellip;')); text("${_(u'Processing your account information …')}");
} }
} }
</script> </script>
......
...@@ -76,13 +76,13 @@ ...@@ -76,13 +76,13 @@
$submitButton. $submitButton.
removeClass('is-disabled'). removeClass('is-disabled').
removeProp('disabled'). removeProp('disabled').
html("${_('Create My {platform_name} Account').format(platform_name=settings.PLATFORM_NAME)}"); text("${_('Create My {platform_name} Account').format(platform_name=settings.PLATFORM_NAME)}");
} }
else { else {
$submitButton. $submitButton.
addClass('is-disabled'). addClass('is-disabled').
prop('disabled', true). prop('disabled', true).
html(gettext('Processing your account information &hellip;')); text("${_(u'Processing your account information…')}");
} }
} }
</script> </script>
......
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