Fixed a bug in the i18n extraction option handling and added a silent option.
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Armin Ronacher · committed by Armin Ronacher · parent 7d268be · Browse files · 4 files·+20 added−2 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+20 added−2 removed
- other:+20 added−2 removed
Provenance
- Commit
1161915- Tree
bba8363- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent
7d268be
4 files changed+20 added−2 removed
modified:docs/extensions.rst+1 added-1 removed
32 unmodified lines33 translatable and calls `gettext`.34 35 After enabling dummy `_` function that forwards calls to `gettext` is added36 to the environment globals. An internationalized application then has to37-provide at least an `gettext` and optoinally a `ngettext` function into the37+provide at least an `gettext` and optionally a `ngettext` function into the38 namespace. Either globally or for each rendering.39 40 Environment Methods41 ~~~~~~~~~~~~~~~~~~~306 unmodified linesmodified:docs/integration.rst+9 added
36 unmodified lines37 :ref:`jinja-extensions` may also be defined by passing a comma separated list38 of import paths as `extensions` value. The i18n extension is added39 automatically.40 41+.. versionchanged:: 2.742+43+ Until 2.7 template syntax errors were always ignored. This was done44+ since many people are dropping non template html files into the45+ templates folder and it would randomly fail. The assumption was that46+ testsuites will catch syntax errors in templates anyways. If you don't47+ want that behavior you can add ``silent=false`` to the settings and48+ exceptions are propagated.49+50 .. _mapping file: http://babel.edgewall.org/wiki/Documentation/messages.html#extraction-method-mapping-and-configuration51 52 Pylons53 ------44 unmodified linesmodified:jinja2/ext.py+9 added-1 removed
550 unmodified lines551 .. versionchanged:: 2.5.1552 The `newstyle_gettext` flag can be set to `True` to enable newstyle553 gettext calls.554 555+ .. versionchanged:: 2.7556+ A `silent` option can now be provided. If set to `False` template557+ syntax errors are propagated instead of being ignored.558+559 :param fileobj: the file-like object the messages should be extracted from560 :param keywords: a list of keywords (i.e. function names) that should be561 recognized as translation functions562 :param comment_tags: a list of translator tags to search for and include11 unmodified lines574 if InternationalizationExtension not in extensions:575 extensions.add(InternationalizationExtension)576 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')580 581+ silent = getbool(options, 'silent', True)582 environment = Environment(583 options.get('block_start_string', BLOCK_START_STRING),584 options.get('block_end_string', BLOCK_END_STRING),585 options.get('variable_start_string', VARIABLE_START_STRING),15 unmodified lines601 try:602 node = environment.parse(source)603 tokens = list(environment.lex(environment.preprocess(source)))604 except TemplateSyntaxError, e:605+ if not silent:606+ raise607 # skip templates with syntax errors608 return609 610 finder = _CommentFinder(tokens, comment_tags)10 unmodified linesmodified:CHANGES+1 added
7 unmodified lines8 - Choice and prefix loaders now dispatch source and template lookup9 separately in order to work in combination with module loaders as10 advertised.11 - Fixed filesizeformat.12+- Added a non-silent option for babel extraction.13 14 Version 2.615 -----------16 (codename Convolution, released on July 24th 2011)263 unmodified lines