我想將HttpResponseRedirect()中的消息翻譯成german.I在我的網站中有一個彈出框,它顯示信息。信息由視圖中聲明的HttpResonseRedirect給出。我把這種information..the代碼是這樣::Django views-如何翻譯HttpResponseRedirect中的信息消息
如果frmChangePassword.is_valid(): 嘗試:
密碼1 = frmChangePassword.cleaned_data [ '密碼1'] 密碼2 = frmChangePassword.cleaned_data ['密碼2 ']
if password1 == password2:
oe = OEConnector()
UpdatePasswordData= oe.updateData('res.users',[request.session['user_id']],{'password':password1})
if UpdatePasswordData:
return HttpResponseRedirect('/Info?info=Password changed successfully.')
else:
return HttpResponseRedirect('/Info?info=Unable to update password. The following error occured -> ' + e.__str__())
else:
return HttpResponseRedirect('/Info?info=Passwords you provided did not match.')
except Exception as e:
return HttpResponseRedirect('/Info?info=Unable to update password. The following error occured -> ' + e.__str__())
elif request.POST['action'] == "newsletter_update":
#Check if newsletter_active checkbox has been checked
#If not, then seeking this value will throw an error
try:
request.POST['newsletter_active']
except:
newsletter_status = False
else:
newsletter_status = True
oe = OEConnector()
UpdateNewsletterData= oe.updateData('res.partner.address',[request.session['partner_id']],{'newsletter_subs':newsletter_status})
return HttpResponseRedirect('/Info?info=Newsletter updated successfully.') .
如何翻譯在HttpResponseRedirect ......我知道有關於gettext的,反,blocktrans,inlinetrans的消息。 由於事先
你說:「當然,沒有問題翻譯的消息」。我無法翻譯我的消息。你介意解釋嗎?我添加了'messages.success(請求,「簽上的成功」)'在我看來,和'{%blocktrans%} {{消息}} {%endblocktrans%}我改變之後將無法正常工作.po文件。我認爲Django無法翻譯變量... – user1011444 2013-03-13 16:41:20