I tried to localize the js files following the Django documentation, but unfortunately, it's not working as expected. Here is a summary of my setup:
settings.py:
LOCALE_PATHS = (os.path.join(BASE_DIR, 'locale'),)
urls.py in the main project directory:
from django.views.i18n import JavaScriptCatalog
from django.conf.urls.i18n import i18n_patterns
urlpatterns += i18n_patterns(
path('jsi18n/', JavaScriptCatalog.as_view(), name='javascript-catalog'),
)
I executed the following commands within the directory and it generated .po and .mo files:
django-admin makemessages -l pt_BR
django-admin makemessages -d djangojs -l pt_BR
django-admin makemessages -a
django-admin compilemessages
django.po file:
msgid "Customer"
msgstr "Cliente"
In the HTML template, I am using the following code:
<script type="text/javascript" src="{% url 'javascript-catalog' %}"></script>
console.log( gettext('Customer') );
Unfortunately, the text remains in English and doesn't get translated. Can anyone provide guidance on what might be causing this issue?