Extract

django_babel.extract.extract_django(fileobj, keywords, comment_tags, options)[source]

Extract messages from Django template files.

Parameters:
  • fileobj – the file-like object the messages should be extracted from
  • keywords – a list of keywords (i.e. function names) that should be recognized as translation functions
  • comment_tags – a list of translator tags to search for and include in the results
  • options – a dictionary of additional options (optional)
Returns:

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

Return type:

iterator

django_babel.extract.trim_whitespace(string)[source]

Trim whitespace.

This is only supported in Django>=1.7. This method help in cases of older Django versions.