djangolocalizationdiacriticsnon-ascii-characters

Django and localization not recognizing strings containing chars with accents


I'm trying to use Django to localize some strings from Italian to other languages. Everything is working fine but not with strings which contain accented chars.

The original file is saved in UTF-8 as well as the translated .po file. The strings are identical and the compilemessages command works without any warning. When I try and open the page though, I don't get the translated version for those strings and only those.

What should I check?


Solution

  • This is valid for Django 0.76:

    {% trans "This is the title." %}

    Everything in the quotes needs to be in standard ASCII. Accented characters won't be recognised. Basically you need to put a label there, and then generate a .po file also for your default language.