Crosstips.org

My fun Crossword solver project. Crosstips.org & Krysstips.se

Kung Fu

Fujian White Crane Kung Fu

Fry-IT

Fry-IT is the company I work for

Photos

Photoalbum, both old and new.

Zope

What I have and am doing with Zope

Receptsamlingen

In Swedish only. About my "Collection of Recipes" website.

Contact me

My contact details and how to contact me.

 

KungFuPeople.com
Do you train Kung Fu?
Or know someone who does?
Then check out KungFuPeople.com


Mobile version of this page Mobile version of this page


 

Nasty surprise of Django and gettext


17th of January 2009

I've done a site that is initially only going to be in Swedish. So I set the LANGUAGE_CODE like this:

 # Language code for this installation. All choices can be found here:
 http://www.i18nguy.com/unicode/language-identifiers.html
 LANGUAGE_CODE = 'sv-SE'

I then go ahead and mark my templates and code and run django-admin.py makemessages -l sv-SE. Then I fire up Poedit to translate the .po file and then compile to make the .mo file, so now I had a file called <my project>/locale/sv-SE/LC_MESSAGES/django.mo but it just wouldn't work!! I tried debugging django.utils.translation with little success. Eventually through trial-and-error I found that if I change it to "sv" instead of "sv-SE" it works.

Is this a problem with gettext or a problem somewhere in Django? It might cause equally much headache for other developers so I wouldn't mind that we get to the bottom of this.



Comment

Ramiro Morales - 17th January 2009  [«« Reply to this]
Try using

LANGUAGE_CODE='sv-se'

and

django-admin.py makemessages -l sv_SE

This is described, granted it's not totally clear, in the Django I18N documentation at:

http://docs.djangoproject.com/en/dev/topics/i18n/#id2

http://docs.djangoproject.com/en/dev/topics/i18n/#message-files

respectively.

HTH
oggy - 19th January 2009  [«« Reply to this]
sv-SE will work just fine but you need to name your directory sv_SE instead of sv-SE
Tome - 19th January 2009  [«« Reply to this]
I spent several hours with trial and error to come up with the same conclusion, finally I used LANGUAGE_CODE='sv' and sv_SE for makemessages.

The documentation is indeed very vague when it comes to this :)
 
Name:
Email:
hide my email address.

Your email address will be encoded to prevent email-extraction spiders from reading it so you won't get spammed if you decide to show your email address.