The horizon.utils.babel_extract_angular ModuleΒΆ

class horizon.utils.babel_extract_angular.AngularGettextHTMLParser[source]

Bases: HTMLParser.HTMLParser

Parse HTML to find translate directives.

Currently this parses for these forms of translation:

<translate>content</translate>
The content will be translated. Angular value templating will be recognised and transformed into gettext-familiar translation strings (i.e. “{$ expression $}” becomes “%(expression)”)
<p translate>content</p>
The content will be translated. As above.
{$ ‘content’ | translate $}
The string will be translated, minus expression handling (i.e. just bare strings are allowed.)
handle_charref(name)[source]
handle_comment(comment)[source]
handle_data(data)[source]
handle_endtag(tag)[source]
handle_entityref(name)[source]
handle_starttag(tag, attrs)[source]
horizon.utils.babel_extract_angular.extract_angular(fileobj, keywords, comment_tags, options)[source]

Extract messages from angular template (HTML) files that use the angular-gettext translate directive as per https://angular-gettext.rocketeer.be/ .

Parameters:
  • fileobj – the file-like object the messages should be extracted from
  • keywords – This is a standard parameter so it isaccepted but ignored.
  • comment_tags – This is a standard parameter so it is accepted but ignored.
  • options – Another standard parameter that is accepted but ignored.
Returns:

an iterator over (lineno, funcname, message, comments) tuples

Return type:

iterator

Previous topic

The horizon.utils.functions Module

Next topic

The horizon.utils Module

Project Source

This Page