【问题标题】:Pyramid localization: not created .pot file金字塔本地化:未创建 .pot 文件
【发布时间】:2015-07-02 00:31:42
【问题描述】:

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

这种行为的原因是什么?

【问题讨论】:

    标签: python localization pyramid mako


    【解决方案1】:

    你还需要和 setup.py 在同一目录下的 setup.cfg,大致包含以下内容:

    [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 文件曾经是金字塔 1.5 之前项目的一部分,但现在金字塔使用 lingua 和 gettext 而不是 babel,它不再需要了。如果您遵循当前的金字塔文档,您可能会更好: http://pyramid.readthedocs.org/en/latest/narr/i18n.html

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-09-29
      相关资源
      最近更新 更多