I use python gettext module. It is fine when I use language=en_US, but it raises an error when I use another language (e.g:vi_VN). Have I done something wrong?
trans = gettext.translation(domain, os.path.join(os.getcwd(), 'locales'), [language])
The locales folder in my project:
locales/
├── en_US
│ └── LC_MESSAGES
│ └── i38.po
└── vi_VN
└── LC_MESSAGES
├── i38.mo
└── i38.po
Error
Traceback (most recent call last):
File "root.py", line 25, in <module>
trans = gettext.translation(domain, os.path.join(os.getcwd(), 'locales'), [language])
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/gettext.py", line 410, in translation
t = _translations.setdefault(key, class_(fp))
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/gettext.py", line 160, in __init__
self._parse(fp)
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/gettext.py", line 300, in _parse
catalog[str(msg, charset)] = str(tmsg, charset)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe1 in position 5: ordinal not in range(128)