gettext翻译不适用于生产系统 [英] gettext translation not working on production system
问题描述
我使用django的 gettext
翻译字符串(在管理员中)遇到一个奇怪的问题:本地运行dev服务器,所有的翻译都在管理员中正确显示,但是当项目部署在生产服务器上时,一些字符串根本不翻译。我无法确定任何系统后面的字符串受到影响,哪些不是!
给你一个印象,例如。一个模型定义如下:
class公司(models.Model):
pre>
....
class Meta:
verbose_name = _('Company Profile')
verbose_name_plural = _('公司简介')
使用dev服务器,该模型的名称在管理员中以不同的语言正确显示,在生产服务器上不是!这影响了一些模型,其他的没有...这是驱使我真的很棒,因为我几乎没有一个想法如何调试这个...
解决方案几种可能性:
- 生产服务器看不到已编译的消息
- 未翻译的消息被标记为
fuzzy
- _()解析为
ugettext
而不是ugettext_lazy
I've encountered a strange problem when translating strings (in the admin) using django's gettext
: Locally running the dev server all translations are displayed correctly in the admin, but when the project is deployed on the production server some strings are not translated at all. I cannot determine any system behind which strings are affected and which not!
To give you an impression, eg. a model is defined like:
class Company(models.Model):
....
class Meta:
verbose_name = _('Company Profile')
verbose_name_plural = _('Company Profiles')
Using dev server the model's name shows up correctly in different languages in the admin, on the production server not! This affects some models, others not... This is driving me really nuts, since I hardly have a idea on how to debug this...
A few possibilities:
- production server doesn't see the compiled messages
- the untranslated messages are marked as
fuzzy
- _() resolves to
ugettext
instead ofugettext_lazy
这篇关于gettext翻译不适用于生产系统的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!