i18n在英雄的生产环境中不起作用 [英] i18n doesn't work at production environment on heroku
问题描述
我已经看到超过一百个关于i18n问题的帖子,没有解决方案似乎解决了我的问题。
I have seen more than one hundred posts about i18n issues and no solution seems to solve my problem.
我有一个运行Django 1.3.1的应用程序在我的开发机器上工作得很好。但是当我带来 heroku 没有任何反应。这些文件根本不翻译。似乎没有找到我的项目中的区域设置文件夹。
I have an app running with Django 1.3.1 and it works Fine at my develop machine. But when I bring to heroku nothing happens. The files are not translated at all. It seems that the locale folder in my project is not being found.
区域设置文件夹位于我的项目级别,这是我的设置:
Locale folder is at my project level and this is my settings:
BASE_PATH = os.path.dirname(os.path.abspath(__file__))
LANGUAGE_CODE = 'pt-br'
USE_I18N = True
USE_L10N = True
ugettext = lambda s: s
LANGUAGES = (
('en-us', ugettext('English')),
('pt-br', ugettext('Portuguese')),
)
LOCALE_PATHS = (
os.path.join(BASE_PATH, "locale"),
)
结构:
locale
pt_BR
LC_MESAGES
django.mo
django.po
推荐答案
在上面的示例中,你写了 LC_MESAGES
而不是 LC_MESSAGES
(注意双S),我相信这很可能是你r问题。
In the sample above you wrote LC_MESAGES
instead of LC_MESSAGES
(notice the double S), I believe this very well could be your issue.
如果没有,请阅读!
最近我有这个问题(再次!)答案在这部分django中找到文档
I had this issue (again!) recently, and the answer was found in this part of the django documentation
我怀疑你的管理员应用程序已翻译但不是您自己的(项目)应用程序,因此具有相同的问题。
I suspect you have the same issue since your "admin" app was translated but not your own (project) app.
似乎Django正在寻找您的翻译:
It seems that Django is looking for your translations like so:
- LOCALE_PATHS中列出的目录具有最高优先级,
首先出现的优先级高于稍后出现的
。 - 然后,它查找并使用如果在INSTALLED_APPS中列出的每个已安装的应用程序中都存在一个locale
目录。最初出现在
之前的
的优先级高于
。最后,Django提供的
django / conf / locale中的基本翻译用作回退。
使用上述设置,您必须确保您的树看起来像这样(最重要的是settings.py位于locale目录下方的目录中):
With the settings you described above, you must make sure your tree looks something like this (with the most important being settings.py is in the dir above the 'locale' dir):
+-project_top/
|
+-project_app/
| |
| +-locale/
| | |
| | +-pt_BR/
| | |
| | +-LC_MESSAGES/
| | |
| | +-django.po
| |
| +-settings.py
|
+-manage.py
这篇关于i18n在英雄的生产环境中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!