我无法获得在 Flask Babel 中工作的基本翻译。
这是我的步骤。
我在页面中有这个
{{_("Hello")}}
我运行这个命令。
pybabel extract -F babel.cfg -o messages.pot .
然后我为德语运行这个命令。
pybabel init -i messages.pot -d translations -l de
这是德语的mo文件
/app/translations/de/LC_MESSAGES/messages.po
# German translations for PROJECT. # Copyright (C) 2012 ORGANIZATION # This file is distributed under the same license as the PROJECT project. # FIRST AUTHOR <EMAIL@ADDRESS>, 2012. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PROJECT VERSION\n" "Report-Msgid-Bugs-To: EMAIL@ADDRESS\n" "POT-Creation-Date: 2012-09-24 03:36+0800\n" "PO-Revision-Date: 2012-09-24 03:37+0800\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: de <LL@li.org>\n" "Plural-Forms: nplurals=2; plural=(n != 1)\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Generated-By: Babel 0.9.6\n" #: templates/baseh5.html:129 msgid "Hello" msgstr "Guten Tag"
我运行这个命令。
pybabel compile -d translations
这就是我得到的。
catalog 'translations/de/LC_MESSAGES/messages.po' is marked as fuzzy, skipping
设置这是烧瓶
app.config['BABEL_DEFAULT_LOCALE'] = 'de'
我能得到什么?我明白了Hello
。为什么 Flask Babel 不起作用?我该如何处理模糊?这应该是基本的。