【发布时间】: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