Why is Django only showing some of my translations

送分小仙女□ 提交于 2020-01-25 03:09:14

问题


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:


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.



来源:https://stackoverflow.com/questions/4165799/why-is-django-only-showing-some-of-my-translations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!