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")?
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With