i18n Class

Inheritance diagram of i18n

i18n

nicer import names

alias of InternationalizationExtension

Methods

__init__(environment)
attr(name[, lineno]) Return an attribute node for the current extension.
bind(environment) Create a copy of this extension bound to another environment.
call_method(name[, args, kwargs, dyn_args, ...]) Call a method of the extension.
filter_stream(stream) It’s passed a TokenStream that can be used
parse(parser) Parse a translatable tag.
preprocess(source, name[, filename]) This method is called before the actual lexing and can be used to preprocess the source.

Attributes

identifier str(object) -> string
priority int(x[, base]) -> integer
tags set() -> new empty set object

Descriptions

class i18n

Method details

__init__(environment)
parse(parser)

Parse a translatable tag.

Attribute details

identifier = 'jinja2.ext.InternationalizationExtension'
tags = set(['trans'])

Inherited member details

attr(name, lineno=None)

Return an attribute node for the current extension. This is useful to pass constants on extensions to generated template code.

self.attr('_my_attribute', lineno=lineno)
bind(environment)

Create a copy of this extension bound to another environment.

call_method(name, args=None, kwargs=None, dyn_args=None, dyn_kwargs=None, lineno=None)

Call a method of the extension. This is a shortcut for attr() + jinja2.nodes.Call.

filter_stream(stream)

It’s passed a TokenStream that can be used to filter tokens returned. This method has to return an iterable of Tokens, but it doesn’t have to return a TokenStream.

In the ext folder of the Jinja2 source distribution there is a file called inlinegettext.py which implements a filter that utilizes this method.

preprocess(source, name, filename=None)

This method is called before the actual lexing and can be used to preprocess the source. The filename is optional. The return value must be the preprocessed source.

priority = 100

Table Of Contents

Previous topic

do Class

Next topic

loopcontrols Class