Serving i18n js using babel, django, & jinja2

Using django, with jinja2 for rendering and babel for fetching messages

I have some js files that need to be internationalized. I could not understand the syntax for extracting messages from them, which would also allow jinja2 to visualize them. Either jinja2 must learn to read the extracted syntax, or I need to extract from something that jinja2 rendering can do. (Or, do it differently)

removing

If I mark posts in js with

gettext('message')

It only extracts a fine.

Rendering

But jinja2 will not replace gettext calls in js (I return js templates with jinja2 before returning them) - it needs something like

{% trans %}message{% endtrans %}

But this syntax cannot be used to retrieve messages.

Babel extract_javascript babel.messages , equipeed .

+1
1

, , :

{{gettext("message")}} 

( gettext)

JS babel , jinja2 ok.

. :

'{{gettext("message")}}'

extract_javascript . , :

{{gettext("'message'")|safe}}

, .

+1

All Articles