I am creating a Python application that uses a bunch of translated strings. The directory structure containing the specified lines is as follows:
/locales
default.pot
/es_ES
/LC_MESSAGES
default.po
/de_DE
/LC_MESSAGES
default.po
These files default.powere generated by the PHP application, but as far as I know, they comply with the general standard that is necessary for working with implementations gettext.
When I try to use these lines in Python using gettext, the following comes down (this example ran from a directory locales:
>>> import os; os.listdir('.')
['.svn', 'de_DE', 'default.pot', 'eng', 'es_ES', 'fr_FR', 'ja_JP', 'ko_KR', 'pl_PL', 'pt_BR', 'ru_RU']
>>> import os.path
>>> os.path.exists('./es_ES/LC_MESSAGES/default.po')
True
>>> import gettext
>>> ldir = 'es_ES/LC_MESSAGES/'
>>> t = gettext.translation('default',ldir)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/gettext.py", line 469, in translation
IOError: [Errno 2] No translation file found for domain: 'default'
>>>
I am not sure what I am doing wrong here (outside of inexperience with this library and the concept of "domain" in its context).
Am I making a simple mistake? Or do I have a fundamental flaw in my understanding of how this shit works?
Thank!