Added some cleanup to the section of the Lingua extractor handling compound statements:
- try, except and else are replaced with '' (i.e. ignored)
- elif is replaced with if
diff --git a/mako/ext/linguaplugin.py b/mako/ext/linguaplugin.py
index 09ef560..8126df3 100644
--- a/mako/ext/linguaplugin.py
+++ b/mako/ext/linguaplugin.py
@@ -26,14 +26,11 @@
def process_python(self, code, code_lineno, translator_strings):
source = code.getvalue().strip()
if source.endswith(compat.b(':')):
- if source == 'else:':
- source = compat.b('if 1:') # Replace "else" with "if 1"
+ if source in ('try:', 'else:') or source.startswith('except'):
+ source = compat.b('') # Ignore try/except and else
elif source.startswith('elif'):
source = source[2:] # Replace "elif" with "if"
- if source == 'try:' or source.startswith('except'):
- source = compat.b('') # Ignore "try/except" altogether
- else:
- source += compat.b(' pass')
+ source += compat.b('pass')
code = io.BytesIO(source)
for msg in self.python_extractor(
self.filename, self.options, code, code_lineno -1):