From 6fb0baaa25c32340046e40efa5695b0418983124 Mon Sep 17 00:00:00 2001 From: Umair Khan Date: Mon, 13 Jun 2016 11:40:35 +0500 Subject: [PATCH] Mark strings translatable. Following strings are marked translatable: - All strings which are passed to `button.text` or which affect the text of buttons. - All strings passed to `placeholder`. - All strings passed to `compose_error`. Fixes #969 --- static/js/admin.js | 12 ++++++------ static/js/compose.js | 21 ++++++++++++--------- static/js/custom_markdown.js | 4 ++-- static/js/subs.js | 10 +++++----- static/templates/admin_tab.handlebars | 2 +- static/templates/settings_tab.handlebars | 4 ++-- templates/zerver/invite_user.html | 2 +- templates/zerver/right-sidebar.html | 2 +- 8 files changed, 30 insertions(+), 27 deletions(-) diff --git a/static/js/admin.js b/static/js/admin.js index f893b7da81..a7d54f09f7 100644 --- a/static/js/admin.js +++ b/static/js/admin.js @@ -288,7 +288,7 @@ exports.setup_page = function () { button.removeClass("btn-danger"); button.addClass("reactivate"); button.removeClass("deactivate"); - button.text("Reactivate"); + button.text(i18n.t("Reactivate")); row.addClass("deactivated_user"); } }); @@ -313,7 +313,7 @@ exports.setup_page = function () { $("

").addClass("text-error").text($.parseJSON(xhr.responseText).msg) ); } else { - button.text("Failed!"); + button.text(i18n.t("Failed!")); } }, success: function () { @@ -322,7 +322,7 @@ exports.setup_page = function () { button.removeClass("btn-warning"); button.addClass("deactivate"); button.removeClass("reactivate"); - button.text("Deactivate"); + button.text(i18n.t("Deactivate")); row.removeClass("deactivated_user"); } }); @@ -434,7 +434,7 @@ exports.setup_page = function () { button.removeClass("btn-warning"); button.addClass("remove-admin"); button.removeClass("make-admin"); - button.text("Remove admin"); + button.text(i18n.t("Remove admin")); }, error: function (xhr, error) { var status = row.find(".admin-user-status"); @@ -467,7 +467,7 @@ exports.setup_page = function () { button.removeClass("btn-danger"); button.addClass("make-admin"); button.removeClass("remove-admin"); - button.text("Make admin"); + button.text(i18n.t("Make admin")); }, error: function (xhr, error) { var status = row.find(".admin-user-status"); @@ -504,7 +504,7 @@ exports.setup_page = function () { button.removeClass("btn-danger"); button.addClass("reactivate"); button.removeClass("deactivate"); - button.text("Reactivate"); + button.text(i18n.t("Reactivate")); row.addClass("deactivated_user"); row.find(".user-admin-settings").hide(); } diff --git a/static/js/compose.js b/static/js/compose.js index c8b67d89a9..326cdfcd41 100644 --- a/static/js/compose.js +++ b/static/js/compose.js @@ -710,7 +710,7 @@ function check_stream_for_send(stream_name, autosubscribe) { var result = exports.check_stream_existence(stream_name, autosubscribe); if (result === "error") { - compose_error("Error checking subscription", $("#stream")); + compose_error(i18n.t("Error checking subscription"), $("#stream")); $("#compose-send-button").removeAttr('disabled'); $("#sending-indicator").hide(); } @@ -721,14 +721,14 @@ function check_stream_for_send(stream_name, autosubscribe) { function validate_stream_message() { var stream_name = exports.stream_name(); if (stream_name === "") { - compose_error("Please specify a stream", $("#stream")); + compose_error(i18n.t("Please specify a stream"), $("#stream")); return false; } if (page_params.mandatory_topics) { var topic = exports.subject(); if (topic === "") { - compose_error("Please specify a topic", $("#subject")); + compose_error(i18n.t("Please specify a topic"), $("#subject")); return false; } } @@ -740,7 +740,7 @@ function validate_stream_message() { // user has not seen a warning message yet if undefined show_all_everyone_warnings(); // user has not acknowledge the warning message yet - compose_error("Please remove @all / @everyone or acknowledge that you will be spamming everyone!"); + compose_error(i18n.t("Please remove @all / @everyone or acknowledge that you will be spamming everyone!")); return false; } } else { @@ -780,11 +780,12 @@ function validate_stream_message() { // The function checks whether the recipients are users of the realm or cross realm users (bots for now) function validate_private_message() { if (exports.recipient() === "") { - compose_error("Please specify at least one recipient", $("#private_message_recipient")); + compose_error(i18n.t("Please specify at least one recipient"), $("#private_message_recipient")); return false; } else { var private_recipients = util.extract_pm_recipients(compose.recipient()); var invalid_recipients = []; + var context = {}; _.each(private_recipients, function (email) { // This case occurs when exports.recipient() ends with ',' if (email === "") { @@ -800,10 +801,12 @@ function validate_private_message() { }); if (invalid_recipients.length === 1) { - compose_error("The recipient " + invalid_recipients.join() + " is not valid ", $("#private_message_recipient")); + context = {'recipient': invalid_recipients.join()}; + compose_error(i18n.t("The recipient __recipient__ is not valid ", context), $("#private_message_recipient")); return false; } else if (invalid_recipients.length > 1) { - compose_error("The recipients " + invalid_recipients.join() + " are not valid ", $("#private_message_recipient")); + context = {'recipients': invalid_recipients.join()}; + compose_error(i18n.t("The recipients __recipients__ are not valid ", context), $("#private_message_recipient")); return false; } else { return true; @@ -816,12 +819,12 @@ exports.validate = function () { $("#sending-indicator").show(); if (/^\s*$/.test(exports.message_content())) { - compose_error("You have nothing to send!", $("#new_message_content")); + compose_error(i18n.t("You have nothing to send!"), $("#new_message_content")); return false; } if ($("#zephyr-mirror-error").is(":visible")) { - compose_error("You need to be running Zephyr mirroring in order to send messages!"); + compose_error(i18n.t("You need to be running Zephyr mirroring in order to send messages!")); return false; } diff --git a/static/js/custom_markdown.js b/static/js/custom_markdown.js index 0b49c96d39..0178974c3f 100644 --- a/static/js/custom_markdown.js +++ b/static/js/custom_markdown.js @@ -45,13 +45,13 @@ var exports = {}; } function display_subscribe($button, stream_name) { - $button.text('Subscribe to ' + stream_data.canonicalized_name(stream_name)) + $button.text(i18n.t('Subscribe to') + ' ' + stream_data.canonicalized_name(stream_name)) .removeClass('btn-success') .addClass('btn-default'); } function display_unsubscribe($button, stream_name) { - $button.text('Unsubscribe from ' + stream_data.canonicalized_name(stream_name)) + $button.text(i18n.t('Unsubscribe from') + ' ' + stream_data.canonicalized_name(stream_name)) .removeClass('btn-default') .addClass('btn-success'); } diff --git a/static/js/subs.js b/static/js/subs.js index b4acf34431..add3c167ad 100644 --- a/static/js/subs.js +++ b/static/js/subs.js @@ -316,7 +316,7 @@ exports.mark_subscribed = function (stream_name, attrs) { var settings = settings_for_sub(sub); var button = button_for_sub(sub); if (button.length !== 0) { - button.text("Subscribed").addClass("subscribed-button").addClass("btn-success"); + button.text(i18n.t("Subscribed")).addClass("subscribed-button").addClass("btn-success"); // Add the user to the member list if they're currently // viewing the members of this stream if (sub.render_subscribers && settings.hasClass('in')) { @@ -359,7 +359,7 @@ exports.mark_sub_unsubscribed = function (sub) { } else if (sub.subscribed) { stream_list.remove_narrow_filter(sub.name, 'stream'); sub.subscribed = false; - button_for_sub(sub).removeClass("subscribed-button").removeClass("btn-success").removeClass("btn-danger").text("Subscribe"); + button_for_sub(sub).removeClass("subscribed-button").removeClass("btn-success").removeClass("btn-danger").text(i18n.t("Subscribe")); var settings = settings_for_sub(sub); if (settings.hasClass('in')) { settings.collapse('hide'); @@ -503,7 +503,7 @@ exports.setup_page = function () { }); } else { populate_and_fill({streams: []}); - $('#create_stream_button').val("Subscribe"); + $('#create_stream_button').val(i18n.t("Subscribe")); } }; @@ -759,9 +759,9 @@ $(function () { }); $("body").on("mouseover", ".subscribed-button", function (e) { - $(e.target).addClass("btn-danger").text("Unsubscribe"); + $(e.target).addClass("btn-danger").text(i18n.t("Unsubscribe")); }).on("mouseout", ".subscribed-button", function (e) { - $(e.target).removeClass("btn-danger").text("Subscribed"); + $(e.target).removeClass("btn-danger").text(i18n.t("Subscribed")); }); $("#subscriptions-status").on("click", "#close-subscriptions-status", function (e) { diff --git a/static/templates/admin_tab.handlebars b/static/templates/admin_tab.handlebars index cdb3b12110..0705d962f4 100644 --- a/static/templates/admin_tab.handlebars +++ b/static/templates/admin_tab.handlebars @@ -90,7 +90,7 @@

- +
diff --git a/static/templates/settings_tab.handlebars b/static/templates/settings_tab.handlebars index df97fb2755..8baa012630 100644 --- a/static/templates/settings_tab.handlebars +++ b/static/templates/settings_tab.handlebars @@ -267,13 +267,13 @@
+ maxlength=100 placeholder="{{t 'Full Bot Name' }}" value="" />
-{{t "bot" }}@{{ page_params.domain }} + placeholder="{{t 'bot_user_name' }}" value="" />-{{t "bot" }}@{{ page_params.domain }}
diff --git a/templates/zerver/invite_user.html b/templates/zerver/invite_user.html index e80c57d973..c069670c3c 100644 --- a/templates/zerver/invite_user.html +++ b/templates/zerver/invite_user.html @@ -13,7 +13,7 @@
+ placeholder="{{ _('One or more email addresses...') }}">
diff --git a/templates/zerver/right-sidebar.html b/templates/zerver/right-sidebar.html index ef4ad1e02e..1726d72973 100644 --- a/templates/zerver/right-sidebar.html +++ b/templates/zerver/right-sidebar.html @@ -32,7 +32,7 @@
- + {% if show_invites %} {{ _('Invite more users') }}