From 207bf2e1fb99aaab2aa1ce8ad7f71a4a4613774a Mon Sep 17 00:00:00 2001 From: Greg Price Date: Fri, 23 Jun 2017 15:45:29 -0700 Subject: [PATCH] i18n: Recognize a little more Handlebars syntax in makemessages. Usually we write translation expressions as `{{t ... }}`, but `{{ t ... }}` is equally valid as far as Handlebars is concerned, and it matches how we usually write simple variable substitutions, as `{{ ... }}`. So occasionally someone writes `{{ t ... }}`; currently there are two examples of this in the codebase, in `settings/bot-{settings,list-admin}.handlebars`. Probably it'd be good to pick a style and enforce it uniformly, but until we do, the other style shouldn't break translation. --- zerver/management/commands/makemessages.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zerver/management/commands/makemessages.py b/zerver/management/commands/makemessages.py index 9258091be3..404afcee14 100644 --- a/zerver/management/commands/makemessages.py +++ b/zerver/management/commands/makemessages.py @@ -53,8 +53,8 @@ strip_whitespace_left = re.compile(u"\\s+(%s-\\s*(endtrans|pluralize).*?-?%s)" % BLOCK_TAG_START, BLOCK_TAG_END), re.U) regexes = ['{{#tr .*?}}([\s\S]*?){{/tr}}', # '.' doesn't match '\n' by default - '{{t "(.*?)"\W*}}', - "{{t '(.*?)'\W*}}", + '{{\s*t "(.*?)"\W*}}', + "{{\s*t '(.*?)'\W*}}", "i18n\.t\('([^\']*?)'\)", "i18n\.t\('(.*?)',.*?[^,]\)", 'i18n\.t\("([^\"]*?)"\)',