Django I18n javascript_catalog with strange assortment response

I use Django 1.9, React and webpack, I used external resources to load django I18n features like gettext into my javascript files.

It loads as follows:

<script type="text/javascript" src="{% url 'django.views.i18n.javascript_catalog' %}/0"></script>

Here is my webpack configurator:

externals: {
    // require("jquery") is external and available
    //  on the global var jQuery
    "jquery": "jQuery",
    "utils": "utils",
    "gettext":"gettext",
    "django":"django",//I18n functions are encapsulated in the django object

    },

In my jsx files, I load gettext as follows:

import {gettext, interpolate, ngettext} from 'django'

render(){
var login_header_text = gettext("blablabla.");
....

In fact, almost everything works when I use django-admin makemessages -d djangojs -l, it restores a lot of gettext, however some gettext are ignored by the script, so sometimes I need to put gettext at the beginning of my rendering function and then it works ..., I do not know why this is happening.

, , , - . , mo po- webpack, .

, ?

+4

Source: https://habr.com/ru/post/1618431/


All Articles