【问题标题】:Pybabel misses tagged messages in html filesPybabel 遗漏 html 文件中的标记消息
【发布时间】:2017-12-28 23:35:13
【问题描述】:

我正在学习 Miguel Grinberg 的新 Flask 教程,并已完成 i18n/l10n。这一章有一半让人头疼。

首先,pybabel extract -F babel.cfg -k _l -o messages.pot 没有运行。我得到的只是:pybabel: error: no input files or directories specified

无论如何,快速的 Google 搜索显示:pybabel extract -F babel.cfg -k _l -o messages.pot --input-dir=. 将起作用。确实如此。

我在读数中看到了它应该从中提取的所有文件。

...
extracting messages from app/routes.py
extracting messages from app/templates/404.html (extensions="jinja2.ext.autoescape,jinja2.ext.with_")
...

下车,开始生成语言目录。 pybabel init -i messages.pot -d app/translations -l es 运行没有错误,打开文件时看起来不错。当我注意到我的 messages.po 文件比 Miguel 的文件短 100 行时,我开始复制/粘贴翻译。

我仔细查看了我的文件版本,发现虽然 pybabel 可能已经查看了我的所有文件,但它没有从中提取任何内容。

我只能推测添加 --input-dir=. 可能已经改变了一些事情,但是没有它我无法让 pybabel 运行,并且谷歌搜索 pybabel extract babel.cfg messages.pot "no input files" 返回 3 个结果都提到了进行该更改。

对于熟悉 Mega 教程的任何人,pybabel 不会从我的 base.html、_post.html 或 user.html 文件中提取任何内容。

【问题讨论】:

    标签: python flask python-babel


    【解决方案1】:

    我认为您的错误在于提取命令。应该是:

    pybabel extract -F babel.cfg -k _l -o messages.pot .
    

    注意messages.pot 后面的点。这是 pybabel 需要开始扫描文件的目录。我什至不知道--input-dir 选项,你在哪里找到的?它没有在 extract command 的 pybabel 文档中列出。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-23
      • 1970-01-01
      • 2011-11-16
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多