问题
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