3

I have this problem: When i set a language (it or en)in my django app, with this form, the javascript strings are converted always in English. My base Language is Italian.

This is my configuration: urls.py:

js_info_dict = { 'domain': 'djangojs', 'packages': ('myproject',), }

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

I have run this command:

django-admin.py makemessages -d djangojs -l en

To generating the djangojs.mo/po files. I Have translated the string from it to en in that file. and i've run:

django-admin.py compilemessages

Now when I go on the page that contains this JS:

document.write(gettext('Questa stringa è da tradurre'));

the strings return always 'This string is to be translated', (That is the translation of 'Questa stringa è da tradurre')

I have included this js in my html file:

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

Where am i wrong? Any Ideas? Thanks in advance.

2
  • Cna you post the example lines from your po file? Commented Apr 22, 2011 at 2:31
  • This. Thanks. Commented Apr 22, 2011 at 9:59

2 Answers 2

10

you should run

django-admin.py makemessages -d djangojs -l en
django-admin.py compilemessages

for each language you have :)

Sign up to request clarification or add additional context in comments.

1 Comment

Another tip: Must be added myproject on installed apps! Cheers.
0

In your file base.html add the following lines to the beginning

{% load static from staticfiles %}
{% load i18n %}
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.