Flask Babel - 'translations / de / LC_MESSAGES / messages.po' marked as fuzzy, skipping

I can’t get the basic translation for working in Flask Babel.

Here are my steps.

  • I have it on the page {{_("Hello")}}

  • I run this command.

     pybabel extract -F babel.cfg -o messages.pot . 
  • Then I ran this command for German.

     pybabel init -i messages.pot -d translations -l de 
  • Here is the mo file for german in /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" 
  • I run this command.

     pybabel compile -d translations 

    This is what I get.

     catalog 'translations/de/LC_MESSAGES/messages.po' is marked as fuzzy, skipping 
  • install this flask

     app.config['BABEL_DEFAULT_LOCALE'] = 'de' 

What will I get? I get Hello . Why is Flask Babel not working? How do I work with fuzzy? This was supposed to be the main one.

+8
python flask babel
source share
2 answers

You can force pybabel compile compile messages marked as fuzzy using the -f (or --use-fuzzy ) command line:

 pybabel compile -f -d translations 

Fuzzy messages are marked with a line #, fuzzy above the msgid line and are the result of merging when the message is considered slightly modified from the previous version. A message marked fuzzy must be reviewed by a person to make sure the translation does not need to be updated, after which the human translator deletes this flag.

+8
source share

As pybabel said: the directory itself was marked as "fuzzy" (6th line). If you delete this line, you do not need the "force" option.

+3
source share

All Articles