class documentation

class InternationalizationExtension(Extension): (source)

View In Hierarchy

This extension adds gettext support to Jinja.

Method __init__ Undocumented
Method parse Parse a translatable tag.
Class Variable tags Undocumented
Method _extract Undocumented
Method _install Undocumented
Method _install_callables Undocumented
Method _install_null Undocumented
Method _make_node Generates a useful node from the data provided.
Method _parse_block Parse until the next block tag with a given name.
Method _trim_whitespace Undocumented
Method _uninstall Undocumented

Inherited from Extension:

Method __init_subclass__ Undocumented
Method attr Return an attribute node for the current extension. This is useful to pass constants on extensions to generated template code.
Method bind Create a copy of this extension bound to another environment.
Method call_method Call a method of the extension. This is a shortcut for :meth:`attr` + :class:`jinja2.nodes.Call`.
Method filter_stream It's passed a :class:`~jinja2.lexer.TokenStream` that can be used to filter tokens returned. This method has to return an iterable of :class:`~jinja2.lexer.Token`\s, but it doesn't have to return a :class:`~jinja2...
Method preprocess 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.
Class Variable identifier Undocumented
Class Variable priority Undocumented
Instance Variable environment Undocumented
def __init__(self, environment): (source)

Undocumented

Parameters
environment:EnvironmentUndocumented
def parse(self, parser): (source)

Parse a translatable tag.

Parameters
parser:ParserUndocumented
Returns
t.Union[nodes.Node, t.List[nodes.Node]]Undocumented
tags: set[str] = (source)

Undocumented

def _extract(self, source, gettext_functions=GETTEXT_FUNCTIONS): (source)

Undocumented

Parameters
source:t.Union[str, nodes.Template]Undocumented
gettext_functions:t.Sequence[str]Undocumented
Returns
t.Iterator[t.Tuple[int, str, t.Union[t.Optional[str], t.Tuple[t.Optional[str], ...]]]]Undocumented
def _install(self, translations, newstyle=None): (source)

Undocumented

Parameters
translations:_SupportedTranslationsUndocumented
newstyle:t.Optional[bool]Undocumented
def _install_callables(self, gettext, ngettext, newstyle=None, pgettext=None, npgettext=None): (source)

Undocumented

Parameters
gettext:t.Callable[[str], str]Undocumented
ngettext:t.Callable[[str, str, int], str]Undocumented
newstyle:t.Optional[bool]Undocumented
pgettext:t.Optional[t.Callable[[str, str], str]]Undocumented
npgettext:t.Optional[t.Callable[[str, str, str, int], str]]Undocumented
def _install_null(self, newstyle=None): (source)

Undocumented

Parameters
newstyle:t.Optional[bool]Undocumented
def _make_node(self, singular, plural, context, variables, plural_expr, vars_referenced, num_called_num): (source)

Generates a useful node from the data provided.

Parameters
singular:strUndocumented
plural:t.Optional[str]Undocumented
context:t.Optional[str]Undocumented
variables:t.Dict[str, nodes.Expr]Undocumented
plural_expr:t.Optional[nodes.Expr]Undocumented
vars_referenced:boolUndocumented
num_called_num:boolUndocumented
Returns
nodes.OutputUndocumented
def _parse_block(self, parser, allow_pluralize): (source)

Parse until the next block tag with a given name.

Parameters
parser:ParserUndocumented
allow_pluralize:boolUndocumented
Returns
t.Tuple[t.List[str], str]Undocumented
def _trim_whitespace(self, string, _ws_re=_ws_re): (source)

Undocumented

Parameters
string:strUndocumented
_ws_re:t.Pattern[str]Undocumented
Returns
strUndocumented
def _uninstall(self, translations): (source)

Undocumented

Parameters
translations:_SupportedTranslationsUndocumented