I work with Django internationalization features to create translation strings for webapp.
There is a problem when I try to call makemessages
, and the existing .po
language file contains a special character (e.g. $
, ยฃ
, etc.).
If one of them exists, makemessages tries to load the existing .po
file and decode it. When he does this, I get an error message:
Traceback (most recent call last): File "manage.py", line 18, in <module> execute_from_command_line(sys.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 354, in execute_from_command_line utility.execute() File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 346, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 394, in run_from_argv self.execute(*args, **cmd_options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 445, in execute output = self.handle(*args, **options) File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/makemessages.py", line 325, in handle self.write_po_file(potfile, locale) File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/makemessages.py", line 458, in write_po_file msgs, errors, status = gettext_popen_wrapper(args) File "/usr/local/lib/python2.7/dist-packages/django/core/management/commands/makemessages.py", line 51, in gettext_popen_wrapper stdout = stdout.decode(stdout_encoding) File "/usr/lib/python2.7/encodings/utf_8.py", line 16, in decode return codecs.utf_8_decode(input, errors, True) UnicodeEncodeError: 'ascii' codec can't encode character u'\xa2' in position 2105: ordinal not in range(128)
I tried to get back on the track, but I do not understand what is happening.
It seems that Django is trying to decode the existing .po
file as UTF8
, but then when re-encoding it uses the ASCII
codec.
Any ideas as to what is wrong will be widely appreciated.
Edit:
- OS: Ubuntu 15.10 and OS X 10.11.6
- Python: 2.7.10 and 2.7.11
- Django: 1.8.14
- Six: 1.10.0
I tried reinstalling Django / Six as suggested, but the error still exists.
Ubuntu localedef --list-archive
:
en_AG en_AG.utf8 en_AU.utf8 en_BW.utf8 en_CA.utf8 en_DK.utf8 en_GB.utf8 en_HK.utf8 en_IE.utf8 en_IN en_IN.utf8 en_NG en_NG.utf8 en_NZ.utf8 en_PH.utf8 en_SG.utf8 en_US.utf8 en_ZA.utf8 en_ZM en_ZM.utf8 en_ZW.utf8
Content type of the problem translation file:
"Content-Type: text/plain; charset=UTF-8\n"