金字塔定位:未创建。pot fi

2024-05-23 15:20:08 发布

您现在位置:Python中文网/ 问答频道 /正文

我需要本地化我的金字塔应用程序,但我有一个问题。 setup.py文件包含以下message_extractors变量:

message_extractors = { '.': [
      ('templates/**.html', 'mako', None),
      ('templates/**.mako', 'mako', None),
      ('static/**', 'ignore', None)
]},

我已经创建了目录my_package_name/locale。在__init__.py中,我添加了config.add_translation_dirs('my_package_name:locale')。在

但是,当我跑
(my_virtual_env): python setup.py extract_messages

我收到消息

^{pr2}$

如果我理解正确,extract_messages在本例中不需要--output file参数。在

这种行为的原因是什么?在


Tags: 文件namepynone应用程序packagemessagemy
1条回答
网友
1楼 · 发布于 2024-05-23 15:20:08

你也需要设置.cfg在同一目录中设置.py,大致包含以下内容:

[compile_catalog]
directory = YOURPROJECT/locale
domain = YOURPROJECT
statistics = true

[extract_messages]
add_comments = TRANSLATORS:
output_file = YOURPROJECT/locale/YOURPROJECT.pot
width = 80

[init_catalog]
domain = YOURPROJECT
input_file = YOURPROJECT/locale/YOURPROJECT.pot
output_dir = YOURPROJECT/locale

[update_catalog]
domain = YOURPROJECT
input_file = YOURPROJECT/locale/YOURPROJECT.pot
output_dir = YOURPROJECT/locale
previous = true

当然,您将用项目名称替换您的项目。我认为设置.cfg在Pyramid1.5之前,文件曾经是项目的一部分,但是现在pyramid使用了lingua和gettext而不是babel,现在不再需要它了。如果您遵循当前的金字塔文档,可能会更好: http://pyramid.readthedocs.org/en/latest/narr/i18n.html

相关问题 更多 >