From fc72009275d6fd2d740958ab4d604f1a5830206b Mon Sep 17 00:00:00 2001 From: Laurent Peuch Date: Wed, 20 Mar 2024 05:39:03 +0100 Subject: [PATCH] doc(readme_generator/i18n): add pybabel documentation in the README --- tools/readme_generator/README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tools/readme_generator/README.md b/tools/readme_generator/README.md index e50f43ba..b0bb0e1d 100644 --- a/tools/readme_generator/README.md +++ b/tools/readme_generator/README.md @@ -44,3 +44,24 @@ Add the webhook.service to systemd config, then start it: ```bash systemctl start the_webhook_service ``` + +## Translation + +It's based on Babel integrated into jinja2 : + +```bash +source venv/bin/activate + +# Extract the english sentences from the code, needed if you modified it +pybabel extract --ignore-dirs venv -F babel.cfg -o messages.pot . + +# If working on a new locale: initialize it (in this example: fr) +pybabel init -i messages.pot -d translations -l fr +# Otherwise, update the existing .po: +pybabel update -i messages.pot -d translations + +# ... translate stuff in translations//LC_MESSAGES/messages.po +# re-run the 'update' command to let Babel properly format the text +# then compile: +pybabel compile -d translations +```