From c3a93c5f6f459e185e53d241d8f4003dbdf9c94c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89loi=20Rivard?= Date: Mon, 24 Jul 2023 19:36:11 +0200 Subject: [PATCH] fix: babel is required at build by the project metadata --- build.py | 18 ++++++++---------- canaille/translations/README.md | 6 +++--- pyproject.toml | 2 +- setup.cfg | 19 ------------------- 4 files changed, 12 insertions(+), 33 deletions(-) delete mode 100644 setup.cfg diff --git a/build.py b/build.py index 551c13b0..7a45edba 100644 --- a/build.py +++ b/build.py @@ -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 diff --git a/canaille/translations/README.md b/canaille/translations/README.md index d9249a75..4b7cf8a4 100644 --- a/canaille/translations/README.md +++ b/canaille/translations/README.md @@ -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 ``` diff --git a/pyproject.toml b/pyproject.toml index 46a0d1b8..94483a7b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [build-system] -requires = ["poetry>=1.0.0"] +requires = ["poetry>=1.0.0", "babel"] build-backend = "poetry.masonry.api" [tool] diff --git a/setup.cfg b/setup.cfg deleted file mode 100644 index 6c7fff47..00000000 --- a/setup.cfg +++ /dev/null @@ -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