fix: babel is required at build by the project metadata

This commit is contained in:
Éloi Rivard 2023-07-24 19:36:11 +02:00
parent 1352752db8
commit c3a93c5f6f
No known key found for this signature in database
GPG key ID: 7EDA204EA57DD184
4 changed files with 12 additions and 33 deletions

View file

@ -1,17 +1,15 @@
import os
import subprocess
def create_mo_files(setup_kwargs):
print("Compile translations:")
subprocess.run(
[
"pybabel",
"compile",
"--directory",
os.path.dirname(__file__) + "/canaille/translations",
]
)
from babel.messages.frontend import compile_catalog
cmd = compile_catalog()
cmd.directory = os.path.dirname(__file__) + "/canaille/translations"
cmd.quiet = True
cmd.statistics = True
cmd.finalize_options()
cmd.run()
return setup_kwargs

View file

@ -5,7 +5,7 @@ All the other steps are automatically done with Weblate.
Extract the messages with:
```
pybabel extract --mapping-file canaille/translations/babel.cfg --output-file canaille/translations/messages.pot canaille
pybabel extract --copyright-holder="Yaal Coop" --output-file canaille/translations/messages.pot canaille
```
Add a new language with:
@ -17,11 +17,11 @@ pybabel init --input-file canaille/translations/messages.pot --output-dir canail
Update the catalogs with:
```
pybabel update --input-file canaille/translations/messages.pot --output-dir canaille/translations
pybabel update --input-file canaille/translations/messages.pot --output-dir canaille/translations --ignore-obsolete --no-fuzzy-matching --update-header-comment
```
Compile the catalogs with:
```
pybabel compile --directory canaille/translations
pybabel compile --directory canaille/translations --statistics
```

View file

@ -1,5 +1,5 @@
[build-system]
requires = ["poetry>=1.0.0"]
requires = ["poetry>=1.0.0", "babel"]
build-backend = "poetry.masonry.api"
[tool]

View file

@ -1,19 +0,0 @@
[extract_messages]
copyright_holder = Yaal Coop Team
input_paths = canaille
output_file = canaille/translations/messages.pot
[init_catalog]
input_file = canaille/translations/messages.pot
output_dir = canaille/translations/
[update_catalog]
input_file = canaille/translations/messages.pot
output_dir = canaille/translations/
update-header-comment = true
no-fuzzy-matching = true
ignore-obsolete = true
[compile_catalog]
directory = canaille/translations/
statistics = true