11. January 2015 2 min read
Django compilemessages error
Django has extremely powerful translation tool, but its error reports are kind of useless. The usage of this tool is simple for every developer. To use this tool you need to set it up in settings.py of your project and use trans template tag in templates to indicated text that needs to be translated. To repeat the basics you usually make messages with
python manage.py makemessages --all
and then you translate the django.po file located in locale/LANGID/LC_MESSAGES/django.po . When you have translated all msgstr fields you compile messages so that Django can use the translations with
python manage.py compilemessages
processing file django.po in
CommandError: Execution of msgfmt failed: locale/si/LC_MESSAGES/django.po:328: number of format
specifications in 'msgid' and 'msgstr' does not match
Now this seems quite funny as its description is totally useless. In fact the error was a Percentage sign, which was in msgid as double percentage. To avoid this think of trans template tag as TAG, and do not write a very long descriptive text in there especially no special characters. When I removed this percentage sign from msgid I could easily use a percentage sign in msgstr, without any doubling etc.