0
votes

The django gettext translation always displays the translated phrase (English), never my original phrase in the html (Dutch).

Normal translation with {% trans "" %} works well. Only the javascript gives this problem.

I don't have a /locale/nl/, as my default strings are already in Dutch.

I've set the translation up as in documentation (in settings, urls.py and html), and with gettext('string') in Javascript file. The Django catalog in http://localhost:8081/jsi18n/ shows the original Dutch strings:

django.catalog = {
"<p>De sluitdatum is verlopen op ": "<p>The closing date has passed on ", 
"<p>De vragenlijst is ": "<p>The questionnaire is ", 
"<p>U bent nog niet geaccepteerd voor deze vragenlijst.</p><p>U ontvangt een uitnodiging per email wanneer u bent geaccepteerd!</p>": "<p>You are not yet accepted for this survey.</p><p>You will receive an invitation by email when you are accepted!</p>", 
"<p>U heeft de vragenlijst voltooid!</p> <p><small>U kunt uw antwoorden nog aanpassen tot de vragenlijst is gesloten.</small></p>": "<p>You have completed the questionnaire!</p> <p><small>You can change your answers until the survey close date</small></p>", 
"Er zijn dubbele emailaddressen gevonden: ": "There are duplicate emailaddresses", 
"Volgende": "Next", 
"Vorige": "Previous"
};

But these sentences never get shown, in Dutch.

1
(we cannot see your localhost urls, so it's useless :). Try replacing it with a screenshot/text/etc.)Marco Acierno
added code. My question is though: maybe this is default django behaviour? Do I need to add english locale files?Jdruiter

1 Answers

0
votes

I think you forgot add translated strings in your djangojs.po file (for original default locale. Dutch in this case).

Or maybe you should add javascript-catalog url inside i18n_patterns():

i18n_urlpatterns = i18n_patterns(
    url(r'^jsi18n/$', javascript_catalog, js_info_dict, name='javascript-catalog'),
)
urlpatterns += i18n_urlpatterns

Notice that in this case Django returns 2 different js files: