templates: Allow the same line-wrapping in {{t}} as in {{#tr}}.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-03-15 17:32:15 -07:00 committed by Tim Abbott
parent ba5a2c8866
commit 8cd78d356f
2 changed files with 10 additions and 5 deletions

View File

@ -62,6 +62,11 @@ Handlebars.registerHelper("t", function (message) {
// Note: use `{` and `}` instead of `{{` and `}}` to declare
// variables.
message = message
.trim()
.split("\n")
.map((s) => s.trim())
.join(" ");
const descriptor = {id: message, defaultMessage: message};
return intl.formatMessage(descriptor, this);
});

View File

@ -53,11 +53,11 @@ strip_whitespace_left = re.compile(
regexes = [
r"{{#tr}}([\s\S]*?)(?:{{/tr}}|{{#\*inline )", # '.' doesn't match '\n' by default
r'{{\s*t "(.*?)"\W*}}',
r"{{\s*t '(.*?)'\W*}}",
r'\(t "(.*?)"\)',
r'=\(t "(.*?)"\)(?=[^{]*}})',
r"=\(t '(.*?)'\)(?=[^{]*}})",
r'{{\s*t "([\s\S]*?)"\W*}}',
r"{{\s*t '([\s\S]*?)'\W*}}",
r'\(t "([\s\S]*?)"\)',
r'=\(t "([\s\S]*?)"\)(?=[^{]*}})',
r"=\(t '([\s\S]*?)'\)(?=[^{]*}})",
]
tags = [
("err_", "error"),