为什么Django只显示我的一些翻译 [英] Why is Django only showing some of my translations

查看:218
本文介绍了为什么Django只显示我的一些翻译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在HTML模板和 views.py 中有一个包含翻译字符串的网站, forms.py models.py 文件。 Django为我的第二种语言创建了 django.po 文件,我已经输入了大部分的翻译。但是,只有我的.html和view.py文件中的翻译才会显示在网站上。其他的被忽略它似乎(models.py,forms.py - 默认为英文)



发生了什么事?



我明显地编译了我的 django.mo 文件,这是正常的 - 否则很多模板字符串不会'不需要翻译 - 所以为什么忽略我的 models.py 翻译。在管理员网站和前端都有。



一个想法是,可能在 django.mo 文件导致它中断。有没有办法测试一个 django.mo 文件的错误?如果发生错误,它会工作吗?



我的项目还安装了Django-cms,这可能会导致一些冲突?



感谢任何灯棚。



Guy

解决方案

1.确保您在模型和表单定义中始终使用 ugettext_lazy (而不是 ugettext )。 p>

2.删除 fuzzy 标签在.mo文件。


I've got a site with translation strings in both the HTML templates and the views.py, forms.py and models.py files. Django has created the django.po file for my second language, and I have entered most of the translations. However, only translations in my .html and view.py files are showing up on the site. the others are being ignored it seems (models.py, forms.py - both defaulting to English)

What's going on?

I've obviously compiled my django.mo file and that's working - otherwise a lot of template strings wouldn't be translated - so why is it ignoring my models.py translations. Both in the admin site and the front end.

One thought is that there may be an error in the django.mo file that causes it to break. Is there any way to test a django.mo file for errors? Would it work at all if there was an error?

My project also has Django-cms installed, which could be causing some conflict?

Thanks for any light shed.

Guy

解决方案

1.Make sure you are always using ugettext_lazy (not ugettext) in model and form definitions

2.Remove possible fuzzy tags in the .mo files.

这篇关于为什么Django只显示我的一些翻译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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