开发者

Problems with multilanguage application in translating models

开发者 https://www.devze.com 2023-01-08 02:18 出处:网络
I\'m writing an application, which will be used in several languages: \'en\', \'de\', \'fr\', \'es\' and \'pl\'. I provided translation strings for every string that needs to be translated, I prepared

I'm writing an application, which will be used in several languages: 'en', 'de', 'fr', 'es' and 'pl'. I provided translation strings for every string that needs to be translated, I prepared the translation files and compiled them.

Then, I set the LANGUAGES variable and added the LocaleMiddleware in settings.py.

The problem is, when I enter the page, say /admin/, the 开发者_如何学JAVAstrings provided as strings are translated properly (I use 'pl' in Accept-Language), but the strings in models and forms (like labels and verbose_names) are displayed in the LANGUAGE_CODE language (when I change the language code, the models are translated).

Anyone got an idea, what's wrong?


have you tried

from django.utils.translation import ugettext as _

verbose_names = _("Eggs")


I've been using ugettext instead of ugettext_lazy. Remember to use the latter for django's strings!

0

精彩评论

暂无评论...
验证码 换一张
取 消