Opened 9 years ago
Closed 9 years ago
#25137 closed Bug (invalid)
IOError "No translation file found" when implementing new Language
Reported by: | ivoarm | Owned by: | nobody |
---|---|---|---|
Component: | Internationalization | Version: | 1.8 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I implemented a new Language called 'ptfm' since Django version 1.5. I never had any problems using versions 1.5 and 1.7, and everything worked just fine.
The way I have this implemented is by adding/configured in settings the following:
EXTRA_LANG_INFO = { 'ptfm': { 'bidi': False, 'code': 'ptfm', 'name': 'Portuguese', 'name_local': u'Português', }, } LANGUAGES = ( ('ptfm', gettext('Portuguese FM')), ) LANGUAGE_CODE = 'ptfm' import django.conf.locale LANG_INFO = dict(django.conf.locale.LANG_INFO.items() + EXTRA_LANG_INFO.items()) django.conf.locale.LANG_INFO = LANG_INFO
Then I have the correct folder in my project for locale/ptfm/LC_MESSAGES/django.(mo and po).
But now I've updated to Django 1.8, and running the server an IOError is thrown:
File "C:\Python27\lib\site-packages\django\utils\translation\__init__.py", line 84, in ugettext return _trans.ugettext(message) File "C:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 327, in ugettext return do_translate(message, 'ugettext') File "C:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 304, in do_translate _default = _default or translation(settings.LANGUAGE_CODE) File "C:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 206, in translation _translations[language] = DjangoTranslation(language) File "C:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 115, in __init__ self._init_translation_catalog() File "C:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 153, in _init_translation_catalog translation = self._new_gnu_trans(localedir, use_null_fallback) File "C:\Python27\lib\site-packages\django\utils\translation\trans_real.py", line 136, in _new_gnu_trans fallback=use_null_fallback) File "C:\Python27\lib\gettext.py", line 472, in translation raise IOError(ENOENT, 'No translation file found for domain', domain) IOError: [Errno 2] No translation file found for domain: u'django'
I think maybe its related with the "Refactored DjangoTranslation class" made here:
https://github.com/django/django/commit/a5f6cbce07b5f3ab48d931e3fd1883c757fb9b45
In this trans_real.py, on function:
def _init_translation_catalog(self): """Creates a base catalog using global django translations.""" settingsfile = upath(sys.modules[settings.__module__].__file__) localedir = os.path.join(os.path.dirname(settingsfile), 'locale')
When trying to run server, this localedir is set to:
u'C:\\Python27\\lib\\site-packages\\django\\conf\\locale'
and then throws the error on gettext.py in translation, because tries to find the MO file for language ptfm inside this localedir and doesn't exist.
I've also tried to append in settings the correct and full location for LOCALE_PATHS but the same error is thrown.
I found the error was the language name as ptfm, and should be pt-FM. The question was this was working until django 1.7.