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.
Comments
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
sv-SE will work just fine but you need to name your directory sv_SE instead of sv-SE
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 :)