参考这个教程做一个简单的例子是可以的:
http://danilodellaquila.com/en/blog/pyramid-internationalization-howto
但往一个比较大的项目中(目录结果很复杂)添加这个功能,对 .po 文件编译到 .mo 文件没问题,但无论在代码中使用 pyramid.i18n
API读取,还是在html中用标签取,都取不到。例如这样:
<h2 i18n:translate="search_documentation">Search documentation</h2>
这里的 i18n:translate
似乎不起作用。
当然在html属性里加了这样的代码:
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
xmlns:tal="http://xml.zope.org/namespaces/tal"
xmlns:i18n="http://xml.zope.org/namespaces/i18n"
i18n:domain="(在setup.cfg里设置的domain名)">
setup.py, setup.cfg, __init__.py, application.ini 里也都做了设置。
实在不知道问题在哪,更不知道如何调试。
注册 locale 查找目录