Question

I've been working away at getting i18n working and having multi lingual versions of my website.

I have a few people kindly doing translations for me, but since I've come into a few problems, scouring the web it seems like a few people have a hard time starting with django's internationalisation and localisation modules.

The main issues that I've come across thus far are:

  1. django.po files do not update when running django-admin.py makemessages -a
  2. When the language files are there when the language is changed there are no changes on the website other than what is pre-built with the django package.†
  3. The i18n/setlang view doesn't work.††

Now, it's only point 1 that I have unresolved. Firstly what's going on that's making makemessages not update? I'm using -a to update all the files I've previously made (de, da, fi) and fi is the only language file that's actually got translations added (the rest are just empty translation strings currently)

†I've now resolved number 2. It seems that when makemessages creates the .po file it does so with a fuzzy tag.

#, fuzzy

According to some research I've done this treats the file as if it's needing to be updated as like the no-op option that comes with the trans tag.

{% trans "translation string" noop %}

Upon removing the #, fuzzy line it has solved this issue.

††I've added number 3 in, just for reference as I've solved that myself. You need to ensure LocaleMiddleware is present in your MIDDLEWARE_CLASSES

MIDDLEWARE_CLASSES = (
    'django.middleware.locale.LocaleMiddleware',
) 
Was it helpful?

Solution

So it seems I was able to answer my own question.

  1. Where I was updating my translation before was outside of the project tree in translations/locale, for some reason I had a message saying that it was deprecated and was not able to do it this way, for some reason now that's changed and it has fixed the issue of makemessages not updating correctly.

  2. remove #, fuzzy tags from translations.

  3. add LocaleMiddleware to the MIDDLEWARE_CLASSES

Problem solved.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top