-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Translations in template vars with a macro are not picked up #27
Comments
It looks like {% call %} is a custom template tag |
It's part of Jinja, yes. I don't think it has to do with that, but rather that it does work within block tags, but not within variable tags that has additional stuff (like a macro call). Just after posting the issue here, we got it to work by reverting to our previous mapping file used by pybabel*: -[django: templates/**.tmpl]
+[jinja2: templates/**.tmpl]
+extensions= jinja2.ext.i18n, jinja2.ext.with_ *To make that work we also added When upgrading, we thought these extension would be picked up from the Django 1.8 template settings, where these extension are also defined: TEMPLATES = [
{
'BACKEND': 'django_jinja.backend.Jinja2',
'OPTIONS': {
'debug': DEBUG,
'match_extension': '.tmpl',
'extensions': [
'jinja2.ext.with_',
'jinja2.ext.i18n',
'django_jinja.builtins.extensions.UrlsExtension',
'django_jinja.builtins.extensions.CsrfExtension',
],
...
}
}
] |
@joeribekker can you create a PR with some tests that use Jinja2 in your usecase? |
You should use Jinja's Babel extractor with Jinja-based templates, not the Django one. |
When upgrading a project from Django 1.6 to 1.8, several libraries had to be updated as well. One of them was BabelDjango 0.2.2 to django-babel 0.4.0.
One particular type of translation in templates was no longer picked up by the extract function in pybabel. When I run
pybabel extract
andpybabel update
on the following template:The output is:
So
test3
is not picked up anymore. I tried several combinations and/or versions of libraries, but could not get it to work with Django 1.8. I also compared the extract functions that both BabelDjango 0.2.2 and django-babel 0.4.0 use and not much changed there. My guess is that the extract function in django-babel does not pick up this translation with Django's template engine changes.Installed packages (where "test3" is not picked up by extract)
Installed packages (where "test3" is picked up by extract)
The text was updated successfully, but these errors were encountered: