找不到域名“ django”的翻译文件 [英] No translation file found for domain 'django'

查看:69
本文介绍了找不到域名“ django”的翻译文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

环境:


  • python 2.7.10

  • django 1.8.6(从站点复制-package文件夹)

我将django发行版复制到了我的项目文件夹中。

I copied the django distribute into my project folder.

认为它会很好地工作

它在我的一台机器上运行正常,但在下面出现了一个错误另一个

It works perfectly in one of my machine, but throw an error below in another one

Traceback (most recent call last):
  File "manage.py", line 12, in <module>
    execute_from_command_line(sys.argv)
  File "cmdb_lib/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "cmdb_lib/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "cmdb_lib/django/core/management/commands/test.py", line 30, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "cmdb_lib/django/core/management/base.py", line 393, in run_from_argv
    self.execute(*args, **cmd_options)
  File "cmdb_lib/django/core/management/commands/test.py", line 74, in execute
    super(Command, self).execute(*args, **options)
  File "cmdb_lib/django/core/management/base.py", line 458, in execute
    translation.activate(saved_locale)
  File "cmdb_lib/django/utils/translation/__init__.py", line 146, in activate
    return _trans.activate(language)
  File "cmdb_lib/django/utils/translation/trans_real.py", line 222, in activate
    _active.value = translation(language)
  File "cmdb_lib/django/utils/translation/trans_real.py", line 206, in translation
    _translations[language] = DjangoTranslation(language)
  File "cmdb_lib/django/utils/translation/trans_real.py", line 115, in __init__
    self._init_translation_catalog()
  File "cmdb_lib/django/utils/translation/trans_real.py", line 153, in _init_translation_catalog
    translation = self._new_gnu_trans(localedir, use_null_fallback)
  File "cmdb_lib/django/utils/translation/trans_real.py", line 136, in _new_gnu_trans
    fallback=use_null_fallback)
  File "/usr/local/lib/python2.7/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'

但是在我的 settings.py 中,我设置了 LANGUAGE_CODE ='en-us'作为默认值!

But in my settings.py I set LANGUAGE_CODE = 'en-us' as default!

这怎么会引发错误?

我试图

cpip安装django ,问题已解决,但我仍然希望在项目中包含django packege。

I tried to pip install django, problem solved ,but I still want to include the django packege in my project.

如何实现?

推荐答案

我想我已经找到了解决方案,我的。 gitignore 文件忽略了.mo文件,我添加了它,现在一切正常

I think I got the solution , my .gitignorefile ignored the .mo file , I added it and everything 's OK now

如果您使用的是git,请检查您的 .gitignore 文件并注释 *。mo

If you are using git, check your .gitignore file and comment*.mo

添加缺少的 .mo 文件,一切都会好起来

add the missing .mofile ,and things will be good

这篇关于找不到域名“ django”的翻译文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆