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
This commit is contained in:
Umair Khan 2016-06-13 11:40:35 +05:00 committed by Tim Abbott
parent 7ec9cb7e93
commit 6fb0baaa25
8 changed files with 30 additions and 27 deletions

View File

@ -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 () {
$("<p>").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();
}

View File

@ -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;
}

View File

@ -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');
}

View File

@ -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) {

View File

@ -90,7 +90,7 @@
<div class="alert" id="admin-emoji-status"></div>
<div class="control-group">
<label for="emoji_name" class="control-label">{{t "Emoji name" }}</label>
<input type="text" name="name" id="emoji_name" placeholder="mouse_face" />
<input type="text" name="name" id="emoji_name" placeholder="{{t 'mouse_face' }}" />
<div class="alert" id="admin-emoji-name-status"></div>
</div>
<div class="control-group">

View File

@ -267,13 +267,13 @@
<div class="control-group">
<label for="create_bot_name" class="control-label">{{t "Full name" }}</label>
<input type="text" name="bot_name" id="create_bot_name" class="required"
maxlength=100 placeholder="Full Bot Name" value="" />
maxlength=100 placeholder="{{t 'Full Bot Name' }}" value="" />
<div><label for="create_bot_name" generated="true" class="text-error"></label></div>
</div>
<div class="control-group">
<label for="bot_short_name" class="control-label">{{t "Username" }}</label>
<input type="text" name="bot_short_name" id="create_bot_short_name" class="required bot_local_part"
placeholder="bot_user_name" value="" />-{{t "bot" }}@{{ page_params.domain }}
placeholder="{{t 'bot_user_name' }}" value="" />-{{t "bot" }}@{{ page_params.domain }}
<div><label for="create_bot_short_name" generated="true" class="text-error"></label></div>
</div>
<div class="control-group new-bot-ui">

View File

@ -13,7 +13,7 @@
<div class="controls">
<textarea rows="2" id="invitee_emails"
name="invitee_emails"
placeholder="One or more email addresses..."></textarea>
placeholder="{{ _('One or more email addresses...') }}"></textarea>
</div>
</div>
<div class="alert" id="invite_status"></div>

View File

@ -32,7 +32,7 @@
<div id="userlist-header">
<h4 class='sidebar-title' id='userlist-title'>{{ _('USERS') }}</h4>
</div>
<input class="user-list-filter" type="text" placeholder="Search people" />
<input class="user-list-filter" type="text" placeholder="{{ _('Search people') }}" />
<ul id="user_presences" class="filters scrolling_list"></ul>
{% if show_invites %}
<a id="invite-user-link" href="#invite-user" data-toggle="modal"><i class="icon-vector-plus-sign"></i>{{ _('Invite more users') }}</a>