gpt4 book ai didi

python - Pyramid 本地化: not created . pot文件

转载 作者:太空宇宙 更新时间:2023-11-04 10:25:07 24 4
gpt4 key购买 nike

我需要本地化我的 Pyramid 应用程序,但我遇到了问题。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

我收到消息

running extract_messages
error: no output file specified`

如果我理解正确,extract_messages 在这种情况下不需要 --output-file 参数。

这种行为的原因是什么?

最佳答案

您还需要 setup.cfg 与 setup.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

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

关于python - Pyramid 本地化: not created . pot文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29829940/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com