当前位置:网站首页>Ioerror: no translation files found for default language zh cn Solutions for

Ioerror: no translation files found for default language zh cn Solutions for

2022-06-22 02:23:00 Menon research monk

1. The problem is shown in

start-up python When it comes to the project , The display service cannot be opened , The error log shows the following problems

The following problems occurred :

  File "/home/cc/.virtualenvs/audioadmin/local/lib/python2.7/site-packages/django/utils/functional.py", line 162, in __mod__
    return six.text_type(self) % rhs
  File "/home/cc/.virtualenvs/audioadmin/local/lib/python2.7/site-packages/django/utils/functional.py", line 119, in __text_cast
    return func(*self.__args, **self.__kw)
  File "/home/cc/.virtualenvs/audioadmin/local/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 89, in ugettext
    return _trans.ugettext(message)
  File "/home/cc/.virtualenvs/audioadmin/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 345, in ugettext
    return do_translate(message, 'ugettext')
  File "/home/cc/.virtualenvs/audioadmin/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 321, in do_translate
    _default = _default or translation(settings.LANGUAGE_CODE)
  File "/home/cc/.virtualenvs/audioadmin/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 228, in translation
    _translations[language] = DjangoTranslation(language)
  File "/home/cc/.virtualenvs/audioadmin/local/lib/python2.7/site-packages/django/utils/translation/trans_real.py", line 134, in __init__
    raise IOError("No translation files found for default language %s." % settings.LANGUAGE_CODE)
IOError: No translation files found for default language zh-cn.
unable to load app 0 (mountpoint='') (callable not found or import error)
Traceback (most recent call last):

The screenshot is as follows :
 Insert picture description here

2. Problem analysis

Find the key error causes through the error log

IOError: No translation files found for default language zh-cn.

I can't find this Chinese package ( My project is a virtual environment that runs on the server , You can also see from the error log )
But I usually use it well , Why can't I use this bag suddenly

Since it can't be used , The small solution is to change to a Chinese package
stay base.py You can change it by setting the package name in ( In itself, these registrations exist django The path of )

  • Simplified Chinese :zh-Hans
  • Traditional Chinese :zh-Hant

If not , Direct replacement of items Django package , Because maybe this package does not exist in this version ( It can be used without affecting the compilation of the whole project )
( Colleagues also changed their bags , Cause my side to affect , So my solution is to go back to that Django Version of )

3. resolvent

Find... Throughout the project LANGUAGE_CODE, Replace it with Django Some packages in the project
 Insert picture description here
It can be replaced by zh-Hans , Recompile successfully

The other way is : Replace Django edition , After all, some versions do not have these packages

原网站

版权声明
本文为[Menon research monk]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206220049534618.html