Programming Project Databases 2019-2020: Campus Carpool
Every single bit of text that has to be translated should be wrapped in the function gettext()
, or the shorter version _()
.
-
To extract the text to be translated, run
pybabel extract -F babel.cfg -k _l -o messages.pot .
in the root directory. This will generate amessages.pot
template file, which contains all bits of text that should be translated. -
To generate a language catalog, run
pybabel init -i messages.pot -d src/translations -l <lang>
, where<lang>
is either 'en', 'fr' or 'nl'. This will create a directorytranslations
insrc
(if it doesn't exist yet), and generate a new catalog with amessages.po
file, where you can manually translate text. -
To compile the
messages.po
file(s), runpybabel compile -d src/translations
, which will create amessages.mo
file permessages.po
file that wasn't compiled yet. -
If you added text to translate (by adding
_()
's) without overwriting what you've already translated, runpybabel extract -F babel.cfg -k _l -o messages.pot .
orpybabel extract -F babel.cfg -k lazy_gettext -o messages.pot .
to update the template file, then runpybabel update -i messages.pot -d src/translations
to update themessages.po
file(s). This last command will merge the already existing file with the newly generated one.