Skip to content
This repository
Browse code

Fixed a bug in the i18n extraction option handling and added a silent…

… option.
  • Loading branch information...
commit 1161915fd7673275f77560ab110963c85cbda676 1 parent 7d268be
Armin Ronacher authored December 15, 2011
1  CHANGES
@@ -9,6 +9,7 @@ Version 2.7
9 9
   separately in order to work in combination with module loaders as
10 10
   advertised.
11 11
 - Fixed filesizeformat.
  12
+- Added a non-silent option for babel extraction.
12 13
 
13 14
 Version 2.6
14 15
 -----------
2  docs/extensions.rst
Source Rendered
@@ -34,7 +34,7 @@ translatable and calls `gettext`.
34 34
 
35 35
 After enabling dummy `_` function that forwards calls to `gettext` is added
36 36
 to the environment globals.  An internationalized application then has to
37  
-provide at least an `gettext` and optoinally a `ngettext` function into the
  37
+provide at least an `gettext` and optionally a `ngettext` function into the
38 38
 namespace.  Either globally or for each rendering.
39 39
 
40 40
 Environment Methods
9  docs/integration.rst
Source Rendered
@@ -38,6 +38,15 @@ that templates use ``%`` as `line_statement_prefix` you can use this code:
38 38
 of import paths as `extensions` value.  The i18n extension is added
39 39
 automatically.
40 40
 
  41
+.. versionchanged:: 2.7
  42
+
  43
+   Until 2.7 template syntax errors were always ignored.  This was done
  44
+   since many people are dropping non template html files into the
  45
+   templates folder and it would randomly fail.  The assumption was that
  46
+   testsuites will catch syntax errors in templates anyways.  If you don't
  47
+   want that behavior you can add ``silent=false`` to the settings and
  48
+   exceptions are propagated.
  49
+
41 50
 .. _mapping file: http://babel.edgewall.org/wiki/Documentation/messages.html#extraction-method-mapping-and-configuration
42 51
 
43 52
 Pylons
10  jinja2/ext.py
@@ -552,6 +552,10 @@ def babel_extract(fileobj, keywords, comment_tags, options):
552 552
        The `newstyle_gettext` flag can be set to `True` to enable newstyle
553 553
        gettext calls.
554 554
 
  555
+    .. versionchanged:: 2.7
  556
+       A `silent` option can now be provided.  If set to `False` template
  557
+       syntax errors are propagated instead of being ignored.
  558
+
555 559
     :param fileobj: the file-like object the messages should be extracted from
556 560
     :param keywords: a list of keywords (i.e. function names) that should be
557 561
                      recognized as translation functions
@@ -571,8 +575,10 @@ def babel_extract(fileobj, keywords, comment_tags, options):
571 575
         extensions.add(InternationalizationExtension)
572 576
 
573 577
     def getbool(options, key, default=False):
574  
-        options.get(key, str(default)).lower() in ('1', 'on', 'yes', 'true')
  578
+        return options.get(key, str(default)).lower() in \
  579
+            ('1', 'on', 'yes', 'true')
575 580
 
  581
+    silent = getbool(options, 'silent', True)
576 582
     environment = Environment(
577 583
         options.get('block_start_string', BLOCK_START_STRING),
578 584
         options.get('block_end_string', BLOCK_END_STRING),
@@ -596,6 +602,8 @@ def getbool(options, key, default=False):
596 602
         node = environment.parse(source)
597 603
         tokens = list(environment.lex(environment.preprocess(source)))
598 604
     except TemplateSyntaxError, e:
  605
+        if not silent:
  606
+            raise
599 607
         # skip templates with syntax errors
600 608
         return
601 609
 

0 notes on commit 1161915

Please sign in to comment.
Something went wrong with that request. Please try again.