diff --git a/docs/translating/internationalization.md b/docs/translating/internationalization.md index 0d1a65ee52..d3bf441340 100644 --- a/docs/translating/internationalization.md +++ b/docs/translating/internationalization.md @@ -258,12 +258,11 @@ If you are passing a translated string to a Handlebars partial, you can use: The syntax for block strings or strings containing variables is: ``` -{{#tr context}} +{{#tr}} Block of English text. {{/tr}} -var context = {'variable': 'variable value'}; -{{#tr context}} +{{#tr}} Block of English text with a {variable}. {{/tr}} ``` diff --git a/static/js/templates.js b/static/js/templates.js index c69ea242b4..2842790eff 100644 --- a/static/js/templates.js +++ b/static/js/templates.js @@ -59,25 +59,22 @@ Handlebars.registerHelper("t", (message) => { return intl.formatMessage(descriptor); }); -Handlebars.registerHelper("tr", function (context, options) { +Handlebars.registerHelper("tr", function (options) { // Marks a block for translation. // Example usage 1: - // {{#tr context}} + // {{#tr}} //
some English text
// {{/tr}} // // Example usage 2: - // {{#tr context}} - //This {variable} will get value from context
+ // {{#tr}} + //This {variable} will get value from the current context
// {{/tr}} // - // Notes: - // 1. `context` is very important. It can be `this` or an - // object or key of the current context. - // 2. Use `{` and `}` instead of `{{` and `}}` to declare - // expressions. + // Note: use `{` and `}` instead of `{{` and `}}` to declare + // variables. const message = options - .fn(context) + .fn(this) .trim() .split("\n") .map((s) => s.trim()) @@ -92,7 +89,7 @@ Handlebars.registerHelper("tr", function (context, options) { ]), ), ...Object.fromEntries( - Object.entries(context ?? {}).map(([key, value]) => [ + Object.entries(this ?? {}).map(([key, value]) => [ key, Handlebars.Utils.escapeExpression(value), ]), diff --git a/static/templates/actions_popover_content.hbs b/static/templates/actions_popover_content.hbs index cb456b6584..92963ee90a 100644 --- a/static/templates/actions_popover_content.hbs +++ b/static/templates/actions_popover_content.hbs @@ -64,7 +64,7 @@Stream will be announced in #{notifications_stream}.
{{/tr}}{{t 'Organization administrators can change this in the organization settings.' }}
diff --git a/static/templates/archive_recipient_row.hbs b/static/templates/archive_recipient_row.hbs index 3a63c24585..602c37496b 100644 --- a/static/templates/archive_recipient_row.hbs +++ b/static/templates/archive_recipient_row.hbs @@ -5,7 +5,7 @@ {{! topic stuff }} @@ -13,7 +13,7 @@ {{! topic link }} diff --git a/static/templates/compose_all_everyone.hbs b/static/templates/compose_all_everyone.hbs index 5d282b485e..0a207651c2 100644 --- a/static/templates/compose_all_everyone.hbs +++ b/static/templates/compose_all_everyone.hbs @@ -1,6 +1,6 @@{{#tr this}}{name} is not subscribed to this stream. They will not be notified unless you subscribe them.{{/tr}}
+{{#tr}}{name} is not subscribed to this stream. They will not be notified unless you subscribe them.{{/tr}}
{{#tr this}}{name} is not subscribed to this stream. They will not be notified if you mention them.{{/tr}}
+{{#tr}}{name} is not subscribed to this stream. They will not be notified if you mention them.{{/tr}}
{{/if}}- {{#tr this}} + {{#tr}} You're not subscribed to this stream. You will not be notified if other users reply to your message. {{/tr}}
diff --git a/static/templates/compose_private_stream_alert.hbs b/static/templates/compose_private_stream_alert.hbs index cef115efe4..4e663abf44 100644 --- a/static/templates/compose_private_stream_alert.hbs +++ b/static/templates/compose_private_stream_alert.hbs @@ -1,5 +1,5 @@- {{#tr this}} + {{#tr}} Are you sure you want to delete {group_name}? {{/tr}}
diff --git a/static/templates/confirm_delete_user_avatar.hbs b/static/templates/confirm_delete_user_avatar.hbs index 26ca53a1de..030cad606b 100644 --- a/static/templates/confirm_delete_user_avatar.hbs +++ b/static/templates/confirm_delete_user_avatar.hbs @@ -1,5 +1,5 @@- {{#tr this}} + {{#tr}} Are you sure you want to delete your profile picture? {{/tr}}
diff --git a/static/templates/confirm_unstar_all_messages.hbs b/static/templates/confirm_unstar_all_messages.hbs index 3dacce78bc..b13ffa6933 100644 --- a/static/templates/confirm_unstar_all_messages.hbs +++ b/static/templates/confirm_unstar_all_messages.hbs @@ -1,5 +1,5 @@- {{#tr this}} + {{#tr}} Would you like to unstar all starred messages? This action cannot be undone. {{/tr}}
diff --git a/static/templates/confirm_unstar_all_messages_in_topic.hbs b/static/templates/confirm_unstar_all_messages_in_topic.hbs index 923e8219b8..c33790b631 100644 --- a/static/templates/confirm_unstar_all_messages_in_topic.hbs +++ b/static/templates/confirm_unstar_all_messages_in_topic.hbs @@ -1,5 +1,5 @@- {{#tr this}} + {{#tr}} Are you sure you want to unstar all messages in topic {topic}? This action cannot be undone. {{/tr}}
diff --git a/static/templates/delete_topic_modal.hbs b/static/templates/delete_topic_modal.hbs index 2aa178f6c4..30c565b5d7 100644 --- a/static/templates/delete_topic_modal.hbs +++ b/static/templates/delete_topic_modal.hbs @@ -7,7 +7,7 @@{{#tr this}}Are you sure you want to permanently delete {topic_name}?{{/tr}}
+{{#tr}}Are you sure you want to permanently delete {topic_name}?{{/tr}}
{{t "Deleting a topic will immediately remove it and its messages for everyone. Other users may find this confusing, especially if they had received an email or push notification related to the deleted messages." }}