Python 金字塔本地化:未创建.pot文件
我需要本地化我的金字塔应用程序,但我有一个问题。Python 金字塔本地化:未创建.pot文件,python,localization,pyramid,mako,Python,Localization,Pyramid,Mako,我需要本地化我的金字塔应用程序,但我有一个问题。 setup.py文件包含以下message\u提取器变量: message_extractors = { '.': [ ('templates/**.html', 'mako', None), ('templates/**.mako', 'mako', None), ('static/**', 'ignore', None) ]}, 我已经创建了目录my\u package\u name/locale。在\u
setup.py
文件包含以下message\u提取器
变量:
message_extractors = { '.': [
('templates/**.html', 'mako', None),
('templates/**.mako', 'mako', None),
('static/**', 'ignore', None)
]},
我已经创建了目录my\u package\u name/locale
。在\uuuu init\uuuu.py
中,我添加了config.add\u translation\u dirs('my\u package\u name:locale')
但是,当我跑步时(my\u virtual\u env):python setup.py extract\u消息
我收到信息
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
当然,您将用项目名称替换您的项目。我认为setup.cfg文件在pyramid 1.5之前是项目的一部分,但现在pyramid使用lingua和gettext而不是babel,不再需要它了。如果您遵循当前的金字塔文档,您可能会过得更好:
您还需要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
当然,您将用项目名称替换您的项目。我认为setup.cfg文件在pyramid 1.5之前是项目的一部分,但现在pyramid使用lingua和gettext而不是babel,不再需要它了。如果您遵循当前的金字塔文档,您可能会过得更好: