Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

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

Anders Kaseorg8cd78d356f70
diff --git a/web/src/templates.js b/web/src/templates.js
index 4cb4ece6a65..0e17c66a3cb 100644
--- a/web/src/templates.js
+++ b/web/src/templates.js
@@ -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);
});
diff --git a/zerver/management/commands/makemessages.py b/zerver/management/commands/makemessages.py
index 05756776ee8..b9c4e70dcd6 100644
--- a/zerver/management/commands/makemessages.py
+++ b/zerver/management/commands/makemessages.py
@@ -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"),