2👍
A little modification made it for me.. Base recipe is as follows,
you might need to add/modify some more to fit your needs.
$ ~ > cp $DJANGO_PATH/utils/translation/ myproject/utils/ -a
and make the modifications given below:
$ ~ > diff $DJANGO_PATH/utils/translation/trans_real.py myproject/utils/translation/trans_real.py -u --- utils/translation/trans_real.py Wed Jan 20 05:07:46 2010 +++ myproject/utils/translation/trans_real.py Wed Jan 20 04:51:39 2010 @@ -435,6 +435,9 @@ endblock_re = re.compile(r"""^\s*endblocktrans$""") plural_re = re.compile(r"""^\s*plural$""") constant_re = re.compile(r"""_\(((?:".*?")|(?:'.*?'))\)""") +jinja_block_re = re.compile(r"""^\s*trans(?:\s+|$)""") +jinja_endblock_re = re.compile(r"""^\s*endtrans$""") def templatize(src): """ @@ -451,7 +454,7 @@ for t in Lexer(src, None).tokenize(): if intrans: if t.token_type == TOKEN_BLOCK: - endbmatch = endblock_re.match(t.contents) + endbmatch = jinja_endblock_re.match(t.contents) pluralmatch = plural_re.match(t.contents) if endbmatch: if inplural: @@ -485,7 +488,7 @@ else: if t.token_type == TOKEN_BLOCK: imatch = inline_re.match(t.contents) - bmatch = block_re.match(t.contents) + bmatch = jinja_block_re.match(t.contents) cmatches = constant_re.findall(t.contents) if imatch: g = imatch.group(1) $ ~ > cp $DJANGO_PATH/core/management/commands/makemessages.py myproject/myapp/management/commands/ $ ~/myproject/ > diff $DJANGO_PATH/core/management/commands/makemessages.py main/management/commands/makemessages.py -u --- /usr/lib/python2.5/site-packages/django/core/management/commands/makemessages.py Wed Jan 20 05:08:37 2010 +++ main/management/commands/makemessages.py Wed Jan 20 05:28:41 2010 @@ -56,7 +56,7 @@ else: settings.configure(USE_I18N = True) - from django.utils.translation import templatize + from myproject.utils.translation import templatize if os.path.isdir(os.path.join('conf', 'locale')): localedir = os.path.abspath(os.path.join('conf', 'locale'))
then calling make messages as follows does the trick
$ ~/myproject/ > ./manage.py mymakemessages -l $LANGUAGE -e .jinja -v 2
my templates are named as templ_name.jinja, you’ll need to replace .jinja
in the command above with whatever extension you use for your template names.
1👍
I’ve added support for this to Coffin, based on this approach:
http://github.com/miracle2k/coffin/commit/ba1a8a510b05074731d383e0dc1f7c21c67ff728
Source:stackexchange.com