如何使用 django 的內化來翻譯下面的代碼片段?
實用程式.py
template = _("Below is the result of your WWE Account verification.\n"
"Thank you!")
django.po
# try
msgid "Below is the result of your WWE Account verification.\nThank you!"
msgstr "A continuación se muestra el resultado de la verificación de su cuenta WWE.\n ?Gracias!"
但是當我執行下面的代碼片段時......
$ python manage.py shell
>>> from django.utils.translation import activate, ugettext_lazy as _
>>> activate('zh-cn')
>>> template = _("Below is the result of your WWE Account verification.\n"
"Thank you!")
>>> template
以下是您的 WWE 帳戶驗證結果。\n謝謝
上面的outouttemplate是錯誤的。我希望有一個如下所示的新行:
以下是您的 WWE 帳戶驗證結果。
謝謝!
要么
Below is the result of your WWE Account verification.
Thank you!
2022 年 3 月 29 日更新
- 事實證明我已經是正確的。我試過
print(template)了,它按預期作業
uj5u.com熱心網友回復:
你試過列印嗎?有時 REPL 不會像列印時那樣顯示字串,而是顯示它的原始內容。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/451329.html
標籤:django 获取文本 django-i18n 宝
上一篇:顯示資料而不使用回圈Django
下一篇:在Django中洗掉物件
