2

我在使用 webpy 时遇到了 i18n 的问题。

我遵循了这个:http ://webpy.org/cookbook/i18n_support_in_template_file

所以,在我的 .wsgi 中有:

#i18n
gettext.install('messages',I18N_PATH,unicode=True)
gettext.translation('messages',I18N_PATH,languages=['fr_FR','en_US']).install(True)

所以我跑了:

pygettext.py -a -v -d messages -o i18n/messages.po controllers/*.py views/*.html 

我已经复制并翻译了messages.po,我还更改了“内容类型”和“内容传输编码:

"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: UTF-8\n"

我运行了这个命令:

msgfmt -v -o i18n/fr_FR/LC_MESSAGES/messages.mo i18n/fr_FR/LC_MESSAGES/messages.po
>>>93 messages traduits.

这是 i18n 文件夹的树状结构:

i18n/:
en_US  fr_FR  messages.po

i18n/en_US:
LC_MESSAGES

i18n/en_US/LC_MESSAGES:
messages.mo  messages.po

i18n/fr_FR:
LC_MESSAGES

i18n/fr_FR/LC_MESSAGES:
messages.mo  messages.po

但是当我进入我的网站时(我的浏览器的语言是“fr_fr”),我没有翻译字符串。

我不知道为什么。有人有想法吗?

谢谢

4

1 回答 1

0

web.py 文档在这里解释了它。

http://webpy.org/cookbook/runtime-language-switch

于 2011-05-04T19:38:50.010 回答