lint: Expand lint check for use of .text() without i18n.

Fixes #3705.
This commit is contained in:
Tim Abbott
2017-02-28 20:36:51 -08:00
parent d9ef6281fa
commit 7fb406b889
8 changed files with 49 additions and 49 deletions

View File

@@ -213,7 +213,7 @@ function make_stream_default(stream_name) {
$(".active_stream_row button").closest("td").html( $(".active_stream_row button").closest("td").html(
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg)); $("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg));
} else { } else {
$(".active_stream_row button").text("Failed!"); $(".active_stream_row button").text(i18n.t("Failed!"));
} }
}, },
}); });
@@ -457,7 +457,7 @@ function _setup_page() {
$("#home-error"), 'alert-error'); $("#home-error"), 'alert-error');
} }
$("#deactivation_user_modal").modal("hide"); $("#deactivation_user_modal").modal("hide");
meta.current_deactivate_user_modal_row.find("button").eq(0).prop("disabled", true).text("Working…"); meta.current_deactivate_user_modal_row.find("button").eq(0).prop("disabled", true).text(i18n.t("Working…"));
channel.del({ channel.del({
url: '/json/users/' + encodeURIComponent(email), url: '/json/users/' + encodeURIComponent(email),
error: function (xhr) { error: function (xhr) {
@@ -466,7 +466,7 @@ function _setup_page() {
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg) $("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg)
); );
} else { } else {
meta.current_deactivate_user_modal_row.find("button").text("Failed!"); meta.current_deactivate_user_modal_row.find("button").text(i18n.t("Failed!"));
} }
}, },
success: function () { success: function () {
@@ -496,7 +496,7 @@ function _setup_page() {
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg) $("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg)
); );
} else { } else {
row.find("button").text("Failed!"); row.find("button").text(i18n.t("Failed!"));
} }
}, },
success: function () { success: function () {
@@ -862,7 +862,7 @@ function _setup_page() {
$("#home-error"), 'alert-error'); $("#home-error"), 'alert-error');
} }
$("#deactivation_stream_modal").modal("hide"); $("#deactivation_stream_modal").modal("hide");
$(".active_stream_row button").prop("disabled", true).text("Working…"); $(".active_stream_row button").prop("disabled", true).text(i18n.t("Working…"));
var stream_name = $(".active_stream_row").find('.stream_name').text(); var stream_name = $(".active_stream_row").find('.stream_name').text();
var stream_id = stream_data.get_sub(stream_name).stream_id; var stream_id = stream_data.get_sub(stream_name).stream_id;
channel.del({ channel.del({
@@ -873,7 +873,7 @@ function _setup_page() {
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg) $("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg)
); );
} else { } else {
$(".active_stream_row button").text("Failed!"); $(".active_stream_row button").text(i18n.t("Failed!"));
} }
}, },
success: function () { success: function () {
@@ -896,7 +896,7 @@ function _setup_page() {
$("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg) $("<p>").addClass("text-error").text(JSON.parse(xhr.responseText).msg)
); );
} else { } else {
btn.text("Failed!"); btn.text(i18n.t("Failed!"));
} }
}, },
success: function () { success: function () {
@@ -945,7 +945,7 @@ function _setup_page() {
$("<p>").addClass("text-error").text($.parseJSON(xhr.responseText).msg) $("<p>").addClass("text-error").text($.parseJSON(xhr.responseText).msg)
); );
} else { } else {
btn.text("Failed!"); btn.text(i18n.t("Failed!"));
} }
}, },
success: function () { success: function () {
@@ -1004,7 +1004,7 @@ function _setup_page() {
success: function () { success: function () {
aliases_info.removeClass("text-error"); aliases_info.removeClass("text-error");
aliases_info.addClass("text-success"); aliases_info.addClass("text-success");
aliases_info.text("Deleted successfully!"); aliases_info.text(i18n.t("Deleted successfully!"));
}, },
error: function (xhr) { error: function (xhr) {
aliases_info.removeClass("text-success"); aliases_info.removeClass("text-success");
@@ -1030,7 +1030,7 @@ function _setup_page() {
$("#id_realm_restricted_to_domain").prop("disabled", false); $("#id_realm_restricted_to_domain").prop("disabled", false);
aliases_info.removeClass("text-error"); aliases_info.removeClass("text-error");
aliases_info.addClass("text-success"); aliases_info.addClass("text-success");
aliases_info.text("Added successfully!"); aliases_info.text(i18n.t("Added successfully!"));
}, },
error: function (xhr) { error: function (xhr) {
aliases_info.removeClass("text-success"); aliases_info.removeClass("text-success");

View File

@@ -534,7 +534,7 @@ $(function () {
$("#yes-bankrupt").hide(); $("#yes-bankrupt").hide();
$("#no-bankrupt").hide(); $("#no-bankrupt").hide();
$(this).after($("<div>").addClass("alert alert-info settings_committed") $(this).after($("<div>").addClass("alert alert-info settings_committed")
.text("Bringing you to your latest messages…")); .text(i18n.t("Bringing you to your latest messages…")));
}); });
(function () { (function () {

View File

@@ -1080,7 +1080,7 @@ $(function () {
.show(); .show();
$(".send-status-close").one('click', abort_xhr); $(".send-status-close").one('click', abort_xhr);
$("#error-msg").html( $("#error-msg").html(
$("<p>").text("Uploading…") $("<p>").text(i18n.t("Uploading…"))
.after('<div class="progress progress-striped active">' + .after('<div class="progress progress-striped active">' +
'<div class="bar" id="upload-bar" style="width: 00%;"></div>' + '<div class="bar" id="upload-bar" style="width: 00%;"></div>' +
'</div>')); '</div>'));
@@ -1097,20 +1097,20 @@ $(function () {
$("#compose-send-button").removeAttr("disabled"); $("#compose-send-button").removeAttr("disabled");
switch (err) { switch (err) {
case 'BrowserNotSupported': case 'BrowserNotSupported':
msg = "File upload is not yet available for your browser."; msg = i18n.t("File upload is not yet available for your browser.");
break; break;
case 'TooManyFiles': case 'TooManyFiles':
msg = "Unable to upload that many files at once."; msg = i18n.t("Unable to upload that many files at once.");
break; break;
case 'FileTooLarge': case 'FileTooLarge':
// sanitizatio not needed as the file name is not potentially parsed as HTML, etc. // sanitization not needed as the file name is not potentially parsed as HTML, etc.
msg = "\"" + file.name + "\" was too large; the maximum file size is 25MiB."; msg = "\"" + file.name + "\"" + i18n.t(" was too large; the maximum file size is 25MiB.");
break; break;
case 'REQUEST ENTITY TOO LARGE': case 'REQUEST ENTITY TOO LARGE':
msg = "Sorry, the file was too large."; msg = i18n.t("Sorry, the file was too large.");
break; break;
default: default:
msg = "An unknown error occured."; msg = i18n.t("An unknown error occured.");
break; break;
} }
$("#error-msg").text(msg); $("#error-msg").text(msg);

View File

@@ -71,7 +71,9 @@ exports.initialize = function () {
invitee_emails.val(''); invitee_emails.val('');
if (page_params.development_environment) { if (page_params.development_environment) {
$('#dev_env_msg').text('In the Zulip development environment, outgoing emails are printed to the run-dev.py console.') // line-wrapped to avoid the i18n linter, since we don't want to translate this.
$('#dev_env_msg').text(
'In the Zulip development environment, outgoing emails are printed to the run-dev.py console.')
.addClass('alert-info') .addClass('alert-info')
.show(); .show();
} }

View File

@@ -112,12 +112,12 @@ exports.save = function (row, from_topic_edited_only) {
data: request, data: request,
success: function () { success: function () {
if (msg_list === current_msg_list) { if (msg_list === current_msg_list) {
row.find(".edit_error").text("Message successfully edited!").removeClass("alert-error").addClass("alert-success").show(); row.find(".edit_error").text(i18n.t("Message successfully edited!")).removeClass("alert-error").addClass("alert-success").show();
} }
}, },
error: function (xhr) { error: function (xhr) {
if (msg_list === current_msg_list) { if (msg_list === current_msg_list) {
var message = channel.xhr_error_message("Error saving edit", xhr); var message = channel.xhr_error_message(i18n.t("Error saving edit"), xhr);
row.find(".edit_error").text(message).show(); row.find(".edit_error").text(message).show();
} }
}, },

View File

@@ -358,7 +358,7 @@ function show_subscription_settings(sub_row) {
}, },
error: function () { error: function () {
loading.destroy_indicator(indicator_elem); loading.destroy_indicator(indicator_elem);
error_elem.removeClass("hide").text("Could not fetch subscriber list"); error_elem.removeClass("hide").text(i18n.t("Could not fetch subscriber list"));
}, },
}); });
@@ -658,7 +658,7 @@ function change_stream_privacy(e) {
$("#stream_privacy_modal").remove(); $("#stream_privacy_modal").remove();
}, },
error: function () { error: function () {
$("#change-stream-privacy-button").text("Try Again"); $("#change-stream-privacy-button").text(i18n.t("Try again"));
}, },
}); });
} }
@@ -1374,13 +1374,13 @@ $(function () {
} }
} else { } else {
error_elem.addClass("hide"); error_elem.addClass("hide");
warning_elem.removeClass("hide").text("User already subscribed"); warning_elem.removeClass("hide").text(i18n.t("User already subscribed"));
} }
} }
function invite_failure() { function invite_failure() {
warning_elem.addClass("hide"); warning_elem.addClass("hide");
error_elem.removeClass("hide").text("Could not add user to this stream"); error_elem.removeClass("hide").text(i18n.t("Could not add user to this stream"));
} }
exports.invite_user_to_stream(principal, stream, invite_success, invite_failure); exports.invite_user_to_stream(principal, stream, invite_success, invite_failure);
@@ -1446,13 +1446,13 @@ $(function () {
} }
} else { } else {
error_elem.addClass("hide"); error_elem.addClass("hide");
warning_elem.removeClass("hide").text("User already not subscribed"); warning_elem.removeClass("hide").text(i18n.t("User is already not subscribed"));
} }
} }
function removal_failure() { function removal_failure() {
warning_elem.addClass("hide"); warning_elem.addClass("hide");
error_elem.removeClass("hide").text("Could not remove user from this stream"); error_elem.removeClass("hide").text(i18n.t("Error removing user from this stream"));
} }
exports.remove_user_from_stream(principal, stream_name, removal_success, exports.remove_user_from_stream(principal, stream_name, removal_success,

View File

@@ -62,18 +62,18 @@ var upload_widget = (function () {
} else if (e.target.files.length === 1) { } else if (e.target.files.length === 1) {
var file = e.target.files[0]; var file = e.target.files[0];
if (file.size > 5 * 1024 * 1024) { if (file.size > 5 * 1024 * 1024) {
input_error.text('File size must be < 5Mb.'); input_error.text(i18n.t('File size must be < 5Mb.'));
input_error.show(); input_error.show();
clear(); clear();
} else if (!is_image_format(file)) { } else if (!is_image_format(file)) {
input_error.text('File type is not supported.'); input_error.text(i18n.t('File type is not supported.'));
input_error.show(); input_error.show();
clear(); clear();
} else { } else {
accept(file); accept(file);
} }
} else { } else {
input_error.text('Please just upload one file.'); input_error.text(i18n.t('Please just upload one file.'));
} }
}); });
@@ -132,18 +132,18 @@ var upload_widget = (function () {
} else if (e.target.files.length === 1) { } else if (e.target.files.length === 1) {
var file = e.target.files[0]; var file = e.target.files[0];
if (file.size > 5 * 1024 * 1024) { if (file.size > 5 * 1024 * 1024) {
input_error.text('File size must be < 5Mb.'); input_error.text(i18n.t('File size must be < 5Mb.'));
input_error.show(); input_error.show();
clear(); clear();
} else if (!is_image_format(file)) { } else if (!is_image_format(file)) {
input_error.text('File type is not supported.'); input_error.text(i18n.t('File type is not supported.'));
input_error.show(); input_error.show();
clear(); clear();
} else { } else {
accept(file); accept(file);
} }
} else { } else {
input_error.text('Please just upload one file.'); input_error.text(i18n.t('Please just upload one file.'));
} }
}); });

View File

@@ -282,10 +282,8 @@ def build_custom_checkers(by_lang):
'frontend_tests/node_tests', 'frontend_tests/node_tests',
'static/js/debug.js']), 'static/js/debug.js']),
'description': 'console.log and similar should not be used in webapp'}, 'description': 'console.log and similar should not be used in webapp'},
{'pattern': 'button\.text\(["\']', {'pattern': '[.]text\(["\'][a-zA-Z]',
'exclude': set(['tools/lint-all', 'description': 'Strings passed to $().text should be wrapped in i18n.t() for internationalization'},
'frontend_tests/node_tests/templates.js']),
'description': 'Argument to button.text should be a literal string enclosed by i18n.t()'},
{'pattern': 'compose_error\(["\']', {'pattern': 'compose_error\(["\']',
'exclude': set(['tools/lint-all']), 'exclude': set(['tools/lint-all']),
'description': 'Argument to compose_error should be a literal string enclosed ' 'description': 'Argument to compose_error should be a literal string enclosed '