Skip to content

Commit

Permalink
[#2799] Jinja2 now translate pages with custom tags
Browse files Browse the repository at this point in the history
  • Loading branch information
tobes committed Aug 6, 2012
1 parent 3f5c05c commit 866bc43
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions ckan/lib/extract.py
Expand Up @@ -2,6 +2,16 @@
from genshi.filters.i18n import extract as extract_genshi
from jinja2.ext import babel_extract as extract_jinja2

jinja_extensions = '''
jinja2.ext.do, jinja2.ext.with_,
ckan.lib.jinja_extensions.SnippetExtension,
ckan.lib.jinja_extensions.CkanExtend,
ckan.lib.jinja_extensions.LinkForExtension,
ckan.lib.jinja_extensions.ResourceExtension,
ckan.lib.jinja_extensions.UrlForStaticExtension,
ckan.lib.jinja_extensions.UrlForExtension
'''

def extract_ckan(fileobj, *args, **kw):
''' Determine the type of file (Genshi or Jinja2) and then call the
correct extractor function.
Expand All @@ -16,6 +26,8 @@ def extract_ckan(fileobj, *args, **kw):
else:
# jinja2
extractor_function = extract_jinja2
# add our custom tags
kw['options']['extensions'] = jinja_extensions
# we've eaten the file so we need to get back to the start
fileobj.seek(0)
return extractor_function(fileobj, *args, **kw)

0 comments on commit 866bc43

Please sign in to comment.