Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django javascript catalog view for i18n internationalization

I'm trying to get javascript_catalog for i18n working, no dice.

Followed the official guide here

I get the following while running:

./manage.py makemessages -d djangojs -l fr_CA --settings=settings.local

"CommandError: errors happened while running msguniq".
msguniq: error while opening "/webapps/.../djangojs.pot" for reading: No such file or directory

I have this in my project's urls.py

js_info_dict = {
    'packages': ('project_name',),
}

urlpatterns += patterns('',
   (r'^jsi18n/$', 'django.views.i18n.javascript_catalog', js_info_dict),
)

Added this is my base template:

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

I have project_name in my INSTALLED_APPS as well.

I tried it from the package level as well as at the individual app level, creating the locale dir and putting the app in 'packages', ...etc. But the regular makemessages works just not the js catalog for the djangojs domain.

Please help.

like image 435
Joe Lones Avatar asked Jan 01 '26 12:01

Joe Lones


1 Answers

Ok, I thought html files that included the 'script' js tag was also handled with the javascript catalog. In fact, from what I can tell only .js files get scanned. When I put

gettext('Text to translate');

in a .js file it worked. The error message above indicates that there was nothing to translate.

like image 185
Joe Lones Avatar answered Jan 03 '26 00:01

Joe Lones



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!