gettext : No translation file found for domain using custom locale folder
Bonjour tout le monde,
J'ai la structure de dossiers suivante :
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
/
|- main.py
|- brainz
| |- __init__.py
| |- Brainz.py
|- datas
|- locale
|- en_US
|- LC_MESSAGES
|- brainz.mo
|- brainz.po |
Dans mon fichier __init__.py j'ai le code suivant :
Code:
1 2 3 4 5 6 7 8 9 10 11
|
import locale
import gettext
import os
current_locale, encoding = locale.getdefaultlocale()
locale_path = '../datas/locale/' + current_locale + '/LC_MESSAGES/'
language = gettext.translation ( 'brainz', locale_path )
language.install() |
Mais quand j'execute mon script j'ai l'erreur suivante :
Code:
1 2 3 4 5 6 7 8 9
|
Traceback (most recent call last):
File "main.py", line 3, in <module>
from brainz.Brainz import *
File "/home/damien/BrainZ/brainz/__init__.py", line 11, in <module>
language = gettext.translation ( 'brainz', locale_path )
File "/usr/lib/python2.6/gettext.py", line 484, in translation
raise IOError(ENOENT, 'No translation file found for domain', domain)
IOError: [Errno 2] No translation file found for domain: 'brainz' |
Franchement, je ne vois pas pourquoi il ne veux pas charger mon fichier mo vu que je lui fournis le chemin complet vers celui-ci.
Quelqu'un aurais-t-il une idée ? Ou mieux saurais comment faire ?
Merci d'avance,
Damien
NB : Je suis débutant en python et encore plus avec gettext.