Skip to content
Myr

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

4 files+20 added−2 removed

modified:docs/extensions.rst+1 added-1 removed
32 unmodified lines
33translatable and calls `gettext`.3435After enabling dummy `_` function that forwards calls to `gettext` is added36to the environment globals. An internationalized application then has to37provide at least an `gettext` and optoinally a `ngettext` function into the37provide at least an `gettext` and optionally a `ngettext` function into the38namespace. Either globally or for each rendering.3940Environment Methods41~~~~~~~~~~~~~~~~~~~
306 unmodified lines
modified:docs/integration.rst+9 added
36 unmodified lines
37:ref:`jinja-extensions` may also be defined by passing a comma separated list38of import paths as `extensions` value. The i18n extension is added39automatically.4041.. versionchanged:: 2.74243 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.4950.. _mapping file: http://babel.edgewall.org/wiki/Documentation/messages.html#extraction-method-mapping-and-configuration5152Pylons53------
44 unmodified lines
modified:jinja2/ext.py+9 added-1 removed
550 unmodified lines
551 .. versionchanged:: 2.5.1552 The `newstyle_gettext` flag can be set to `True` to enable newstyle553 gettext calls.554555 .. versionchanged:: 2.7556 A `silent` option can now be provided. If set to `False` template557 syntax errors are propagated instead of being ignored.558559 :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 include
11 unmodified lines
574 if InternationalizationExtension not in extensions:575 extensions.add(InternationalizationExtension)576577 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')580581 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 lines
601 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 return609610 finder = _CommentFinder(tokens, comment_tags)
10 unmodified lines
modified:CHANGES+1 added
7 unmodified lines
8- 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.1314Version 2.615-----------16(codename Convolution, released on July 24th 2011)
263 unmodified lines