Skip to content Skip to sidebar Skip to footer

Django Javascript Translation Gettext Is Not Defined

My javascript function contains the following: document.getElementById('example').innerHTML = gettext('This is an example'); My urls.py looks like: urlpatterns = [ url(r'^jsi1

Solution 1:

I am not sure, but try checking the order of your script. See, if you are using the gettext() function for the example above before the script tag where you load the javascript-catalog.

Solution 2:

I literally had the same exact issue, even when I had the script tag come before the gettext().

The simple fix was to make sure the catalog came before the app in urlpatterns:

urlpatterns = [

    path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'),
     ...
    <your app>
]

Solution 3:

<scriptsrc="/jsi18n/"></script>

add this before jquery block. Hope this might help

Post a Comment for "Django Javascript Translation Gettext Is Not Defined"