Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask-Babel updating of existing messages.pot file

How to update an existing messages.pot file? For example, I have translated messages.pot file:

....
#: forms.py:11
msgid "Nickname"
msgstr "Имя"

#: forms.py:18
msgid "Wrong email"
msgstr "Неправильный пароль"
....

If I'll mark new text with selector gettext, for example:

flash(gettext('Login successful'))

and run: pybabel extract -F babel.cfg -o messages.pot
I'll receive a new messages.po file:

    ....
#: forms.py:11
msgid "Nickname"
msgstr ""

#: forms.py:18
msgid "Wrong email"
msgstr ""

#: models.py:783
msgid "Login successful"
msgstr ""
....

So, how can I update an existing messages.pot file, saving translated strings ("Nickname", "Wrong email")?

like image 539
user2782936 Avatar asked Sep 16 '13 07:09

user2782936


1 Answers

pot file not for translations, it just list of all strings for translation without specific language.

For real translations used po - text file and mo - binary file with translations. This files will created for any languages that you need. See my files structure:

translations/
translations/ru/
translations/ru/LC_MESSAGES/
translations/ru/LC_MESSAGES/messages.mo
translations/ru/LC_MESSAGES/messages.po
translations/messages.pot

To get all strings for translation:

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

To init po file (first time):

pybabel init -i messages.pot -d . -l ru

To update exist po file:

pybabel update -i messages.pot -d .

To compile po file to mo:

pybabel compile -f -d .

See more in documentation.

like image 184
tbicr Avatar answered Oct 15 '22 15:10

tbicr