From b96c84e6b400e6439720b1e06b382d822a48971b Mon Sep 17 00:00:00 2001 From: Heungsub Lee Date: Fri, 31 Mar 2017 20:15:33 +0900 Subject: [PATCH] Fix extraction bug on nested messages It fixes !487. --- babel/messages/extract.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/babel/messages/extract.py b/babel/messages/extract.py index efddbf5e..ffcfac86 100644 --- a/babel/messages/extract.py +++ b/babel/messages/extract.py @@ -445,7 +445,8 @@ def extract_python(fileobj, keywords, comment_tags, options): translator_comments.append((lineno, value)) break elif funcname and call_stack == 0: - if tok == OP and value == ')': + nested = (tok == NAME and value in keywords) + if (tok == OP and value == ')') or nested: if buf: messages.append(''.join(buf)) del buf[:] @@ -470,6 +471,8 @@ def extract_python(fileobj, keywords, comment_tags, options): messages = [] translator_comments = [] in_translator_comments = False + if nested: + funcname = value elif tok == STRING: # Unwrap quotes in a safe manner, maintaining the string's # encoding -- 2.47.2