我有以下代码行,基本上会返回错误 - 翻译错误 - 以及失败时的视图:
from django.utils.translation import ugettext_lazy as _
.....
return render_to_response('login.html',{'form': form,'error_message':_("User is not in the group %s" % group_name),'settings':SettingsManager.get()},context_instance=RequestContext(request))
我创建了消息文件,然后编译它们。但问题是它只是在我写的时候显示 - 用英文User is not in the group %s" % group_name
。我的django.po文件的一部分:
#: application/views.py:1003
#, python-format
msgid "User is not in the group %s"
msgstr "Kullanıcı %s grubunda değil."
任何想法如何解决?我看不出问题。
P.S:所有其他翻译都像魅力一样,但这不是。
提前致谢。
答案 0 :(得分:0)
尝试
_("User is not in the group %s") % group_name
而不是
_("User is not in the group %s" % group_name)
这样翻译机器就有一个常量字符串可供查找。