validate_stream_message_address_info: Add i18n tags.

Fixes #7076
This commit is contained in:
Umair Khan
2018-02-05 13:21:58 +05:00
committed by Tim Abbott
parent 1a93cd4ffe
commit c415cc74d7
3 changed files with 9 additions and 10 deletions

View File

@@ -104,12 +104,12 @@ people.add(bob);
$('#stream').select(noop); $('#stream').select(noop);
assert(!compose.validate_stream_message_address_info('foobar')); assert(!compose.validate_stream_message_address_info('foobar'));
assert.equal($('#compose-error-msg').html(), "<p>The stream <b>foobar</b> does not exist.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>"); assert.equal($('#compose-error-msg').html(), "translated: <p>The stream <b>foobar</b> does not exist.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>");
sub.subscribed = false; sub.subscribed = false;
stream_data.add_sub('social', sub); stream_data.add_sub('social', sub);
assert(!compose.validate_stream_message_address_info('social')); assert(!compose.validate_stream_message_address_info('social'));
assert.equal($('#compose-error-msg').html(), "<p>You're not subscribed to the stream <b>social</b>.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>"); assert.equal($('#compose-error-msg').html(), "translated: <p>You're not subscribed to the stream <b>social</b>.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>");
global.page_params.narrow_stream = false; global.page_params.narrow_stream = false;
channel.post = function (payload) { channel.post = function (payload) {
@@ -128,14 +128,14 @@ people.add(bob);
payload.success(payload.data); payload.success(payload.data);
}; };
assert(!compose.validate_stream_message_address_info('Frontend')); assert(!compose.validate_stream_message_address_info('Frontend'));
assert.equal($('#compose-error-msg').html(), "<p>You're not subscribed to the stream <b>Frontend</b>.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>"); assert.equal($('#compose-error-msg').html(), "translated: <p>You're not subscribed to the stream <b>Frontend</b>.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>");
channel.post = function (payload) { channel.post = function (payload) {
assert.equal(payload.data.stream, 'Frontend'); assert.equal(payload.data.stream, 'Frontend');
payload.error({status: 404}); payload.error({status: 404});
}; };
assert(!compose.validate_stream_message_address_info('Frontend')); assert(!compose.validate_stream_message_address_info('Frontend'));
assert.equal($('#compose-error-msg').html(), "<p>The stream <b>Frontend</b> does not exist.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>"); assert.equal($('#compose-error-msg').html(), "translated: <p>The stream <b>Frontend</b> does not exist.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>");
channel.post = function (payload) { channel.post = function (payload) {
assert.equal(payload.data.stream, 'social'); assert.equal(payload.data.stream, 'social');

View File

@@ -564,21 +564,19 @@ exports.validate_stream_message_address_info = function (stream_name) {
var response; var response;
var context = {};
context.stream_name = Handlebars.Utils.escapeExpression(stream_name);
switch (check_unsubscribed_stream_for_send(stream_name, switch (check_unsubscribed_stream_for_send(stream_name,
page_params.narrow_stream !== undefined)) { page_params.narrow_stream !== undefined)) {
case "does-not-exist": case "does-not-exist":
response = "<p>The stream <b>" + response = i18n.t("<p>The stream <b>__stream_name__</b> does not exist.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>", context);
Handlebars.Utils.escapeExpression(stream_name) + "</b> does not exist.</p>" +
"<p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>";
compose_error(response, $('#stream')); compose_error(response, $('#stream'));
return false; return false;
case "error": case "error":
compose_error(i18n.t("Error checking subscription"), $("#stream")); compose_error(i18n.t("Error checking subscription"), $("#stream"));
return false; return false;
case "not-subscribed": case "not-subscribed":
response = "<p>You're not subscribed to the stream <b>" + response = i18n.t("<p>You're not subscribed to the stream <b>__stream_name__</b>.</p><p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>", context);
Handlebars.Utils.escapeExpression(stream_name) + "</b>.</p>" +
"<p>Manage your subscriptions <a href='#streams/all'>on your Streams page</a>.</p>";
compose_error(response, $('#stream')); compose_error(response, $('#stream'));
return false; return false;
} }

View File

@@ -68,6 +68,7 @@ IGNORED_PHRASES = [
r"disabled", r"disabled",
# Fragments of larger strings # Fragments of larger strings
(r'your subscriptions on your Streams page'),
(r'Change notification settings for individual streams on your ' (r'Change notification settings for individual streams on your '
'<a href="/#streams">Streams page</a>.'), '<a href="/#streams">Streams page</a>.'),
(r'Looking for our ' (r'Looking for our '