diff --git a/.dockerignore b/.dockerignore index c36a60b5..3e33847d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -14,9 +14,7 @@ CONTRIBUTORS docker-compose.* Dockerfile docs -LICENSE Makefile MANIFEST.in -README.md SECURITY.md tox.ini diff --git a/.gitignore b/.gitignore index 1ec6964a..ef4cc771 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ *.pyc *.egg-info +*.mo dist .venv docs/_build/ diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index d3907241..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,3 +0,0 @@ -include *.md -recursive-include ihatemoney *.py *.yaml *.po *.mo *.html *.css *.js *.eot *.svg *.woff *.txt *.png *.webp *.ini *.cfg *.j2 *.jpg *.gif *.ico *.xml -include LICENSE CONTRIBUTORS diff --git a/Makefile b/Makefile index 47bbdc02..bf917b60 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ remove-install-stamp: update: remove-install-stamp install ## Update the dependencies .PHONY: serve -serve: install ## Run the ihatemoney server +serve: install build-translations ## Run the ihatemoney server @echo 'Running ihatemoney on http://localhost:5000' FLASK_DEBUG=1 FLASK_APP=ihatemoney.wsgi $(VENV)/bin/flask run --host=0.0.0.0 @@ -74,8 +74,8 @@ compress-assets: compress-showcase ## Compress static assets build-translations: ## Build the translations $(VENV)/bin/pybabel compile -d ihatemoney/translations -.PHONY: update-translations -update-translations: ## Extract new translations from source code +.PHONY: extract-translations +extract-translations: ## Extract new translations from source code $(VENV)/bin/pybabel extract --add-comments "I18N:" --strip-comments --omit-header --no-location --mapping-file ihatemoney/babel.cfg -o ihatemoney/messages.pot ihatemoney $(VENV)/bin/pybabel update -i ihatemoney/messages.pot -d ihatemoney/translations/ diff --git a/docs/contributing.md b/docs/contributing.md index a86f7321..78d5a806 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -274,10 +274,9 @@ In order to issue a new release, follow the following steps: make compress-assets -- Build the translations: +- Extract the translations: - make update-translations - make build-translations + make extract-translations - If you're not completely sure of yourself at this point, you can optionally: create a new branch, push it, open a pull request, check diff --git a/hatch_build.py b/hatch_build.py new file mode 100644 index 00000000..d536daed --- /dev/null +++ b/hatch_build.py @@ -0,0 +1,11 @@ +import sys + +from hatchling.builders.hooks.plugin.interface import BuildHookInterface + + +class CustomBuildHook(BuildHookInterface): + def initialize(self, version, build_data): + sys.path.insert(0, "./ihatemoney") + from babel_utils import compile_catalogs + + compile_catalogs() diff --git a/ihatemoney/babel_utils.py b/ihatemoney/babel_utils.py new file mode 100644 index 00000000..a498bce3 --- /dev/null +++ b/ihatemoney/babel_utils.py @@ -0,0 +1,11 @@ +from pathlib import Path + +from babel.messages.frontend import compile_catalog + + +def compile_catalogs(): + cmd = compile_catalog() + cmd.directory = Path(__file__).parent / "translations" + cmd.statistics = True + cmd.finalize_options() + cmd.run() diff --git a/ihatemoney/tests/conftest.py b/ihatemoney/tests/conftest.py index 08d6e891..35f99e27 100644 --- a/ihatemoney/tests/conftest.py +++ b/ihatemoney/tests/conftest.py @@ -3,10 +3,16 @@ from unittest.mock import MagicMock from flask import Flask import pytest +from ihatemoney.babel_utils import compile_catalogs from ihatemoney.currency_convertor import CurrencyConverter from ihatemoney.run import create_app, db +@pytest.fixture(autouse=True, scope="session") +def babel_catalogs(): + compile_catalogs() + + @pytest.fixture def app(request: pytest.FixtureRequest): """Create the Flask app with database""" diff --git a/ihatemoney/translations/bn/LC_MESSAGES/messages.mo b/ihatemoney/translations/bn/LC_MESSAGES/messages.mo deleted file mode 100644 index 7b4bd717..00000000 Binary files a/ihatemoney/translations/bn/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/bn_BD/LC_MESSAGES/messages.mo b/ihatemoney/translations/bn_BD/LC_MESSAGES/messages.mo deleted file mode 100644 index 6cc61e8f..00000000 Binary files a/ihatemoney/translations/bn_BD/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/ca/LC_MESSAGES/messages.mo b/ihatemoney/translations/ca/LC_MESSAGES/messages.mo deleted file mode 100644 index a6b269a5..00000000 Binary files a/ihatemoney/translations/ca/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/cs/LC_MESSAGES/messages.mo b/ihatemoney/translations/cs/LC_MESSAGES/messages.mo deleted file mode 100644 index 1b4b1b83..00000000 Binary files a/ihatemoney/translations/cs/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/de/LC_MESSAGES/messages.mo b/ihatemoney/translations/de/LC_MESSAGES/messages.mo deleted file mode 100644 index 9b03f6ca..00000000 Binary files a/ihatemoney/translations/de/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/el/LC_MESSAGES/messages.mo b/ihatemoney/translations/el/LC_MESSAGES/messages.mo deleted file mode 100644 index e7746e1f..00000000 Binary files a/ihatemoney/translations/el/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/eo/LC_MESSAGES/messages.mo b/ihatemoney/translations/eo/LC_MESSAGES/messages.mo deleted file mode 100644 index d46cd40a..00000000 Binary files a/ihatemoney/translations/eo/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/es/LC_MESSAGES/messages.mo b/ihatemoney/translations/es/LC_MESSAGES/messages.mo deleted file mode 100644 index a8f10777..00000000 Binary files a/ihatemoney/translations/es/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/es_419/LC_MESSAGES/messages.mo b/ihatemoney/translations/es_419/LC_MESSAGES/messages.mo deleted file mode 100644 index 81fec795..00000000 Binary files a/ihatemoney/translations/es_419/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/fa/LC_MESSAGES/messages.mo b/ihatemoney/translations/fa/LC_MESSAGES/messages.mo deleted file mode 100644 index 43a3a59c..00000000 Binary files a/ihatemoney/translations/fa/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/fr/LC_MESSAGES/messages.mo b/ihatemoney/translations/fr/LC_MESSAGES/messages.mo deleted file mode 100644 index 0ead04b0..00000000 Binary files a/ihatemoney/translations/fr/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/he/LC_MESSAGES/messages.mo b/ihatemoney/translations/he/LC_MESSAGES/messages.mo deleted file mode 100644 index a9ddfde3..00000000 Binary files a/ihatemoney/translations/he/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/hi/LC_MESSAGES/messages.mo b/ihatemoney/translations/hi/LC_MESSAGES/messages.mo deleted file mode 100644 index 74ae7cf0..00000000 Binary files a/ihatemoney/translations/hi/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/hu/LC_MESSAGES/messages.mo b/ihatemoney/translations/hu/LC_MESSAGES/messages.mo deleted file mode 100644 index fe90ccbc..00000000 Binary files a/ihatemoney/translations/hu/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/id/LC_MESSAGES/messages.mo b/ihatemoney/translations/id/LC_MESSAGES/messages.mo deleted file mode 100644 index 3901d26f..00000000 Binary files a/ihatemoney/translations/id/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/it/LC_MESSAGES/messages.mo b/ihatemoney/translations/it/LC_MESSAGES/messages.mo deleted file mode 100644 index df64c743..00000000 Binary files a/ihatemoney/translations/it/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/ja/LC_MESSAGES/messages.mo b/ihatemoney/translations/ja/LC_MESSAGES/messages.mo deleted file mode 100644 index e0a0e521..00000000 Binary files a/ihatemoney/translations/ja/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/kn/LC_MESSAGES/messages.mo b/ihatemoney/translations/kn/LC_MESSAGES/messages.mo deleted file mode 100644 index 4a9277e1..00000000 Binary files a/ihatemoney/translations/kn/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/ms/LC_MESSAGES/messages.mo b/ihatemoney/translations/ms/LC_MESSAGES/messages.mo deleted file mode 100644 index 9c58d4de..00000000 Binary files a/ihatemoney/translations/ms/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/nb_NO/LC_MESSAGES/messages.mo b/ihatemoney/translations/nb_NO/LC_MESSAGES/messages.mo deleted file mode 100644 index 52ea457f..00000000 Binary files a/ihatemoney/translations/nb_NO/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/nl/LC_MESSAGES/messages.mo b/ihatemoney/translations/nl/LC_MESSAGES/messages.mo deleted file mode 100644 index 5a0e9c1c..00000000 Binary files a/ihatemoney/translations/nl/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/pl/LC_MESSAGES/messages.mo b/ihatemoney/translations/pl/LC_MESSAGES/messages.mo deleted file mode 100644 index 9787b92f..00000000 Binary files a/ihatemoney/translations/pl/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/pt/LC_MESSAGES/messages.mo b/ihatemoney/translations/pt/LC_MESSAGES/messages.mo deleted file mode 100644 index 0e7ed0e8..00000000 Binary files a/ihatemoney/translations/pt/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/pt_BR/LC_MESSAGES/messages.mo b/ihatemoney/translations/pt_BR/LC_MESSAGES/messages.mo deleted file mode 100644 index 3d649d6b..00000000 Binary files a/ihatemoney/translations/pt_BR/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/ru/LC_MESSAGES/messages.mo b/ihatemoney/translations/ru/LC_MESSAGES/messages.mo deleted file mode 100644 index 2987fec0..00000000 Binary files a/ihatemoney/translations/ru/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/sr/LC_MESSAGES/messages.mo b/ihatemoney/translations/sr/LC_MESSAGES/messages.mo deleted file mode 100644 index 1100d08c..00000000 Binary files a/ihatemoney/translations/sr/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/sv/LC_MESSAGES/messages.mo b/ihatemoney/translations/sv/LC_MESSAGES/messages.mo deleted file mode 100644 index 75799e81..00000000 Binary files a/ihatemoney/translations/sv/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/ta/LC_MESSAGES/messages.mo b/ihatemoney/translations/ta/LC_MESSAGES/messages.mo deleted file mode 100644 index 25e6adb9..00000000 Binary files a/ihatemoney/translations/ta/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/te/LC_MESSAGES/messages.mo b/ihatemoney/translations/te/LC_MESSAGES/messages.mo deleted file mode 100644 index 9949f84a..00000000 Binary files a/ihatemoney/translations/te/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/th/LC_MESSAGES/messages.mo b/ihatemoney/translations/th/LC_MESSAGES/messages.mo deleted file mode 100644 index 41374102..00000000 Binary files a/ihatemoney/translations/th/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/tr/LC_MESSAGES/messages.mo b/ihatemoney/translations/tr/LC_MESSAGES/messages.mo deleted file mode 100644 index 7c027fe4..00000000 Binary files a/ihatemoney/translations/tr/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/uk/LC_MESSAGES/messages.mo b/ihatemoney/translations/uk/LC_MESSAGES/messages.mo deleted file mode 100644 index dfb9b475..00000000 Binary files a/ihatemoney/translations/uk/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/ur/LC_MESSAGES/messages.mo b/ihatemoney/translations/ur/LC_MESSAGES/messages.mo deleted file mode 100644 index e9bb034d..00000000 Binary files a/ihatemoney/translations/ur/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/vi/LC_MESSAGES/messages.mo b/ihatemoney/translations/vi/LC_MESSAGES/messages.mo deleted file mode 100644 index c26a756a..00000000 Binary files a/ihatemoney/translations/vi/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/ihatemoney/translations/zh_Hans/LC_MESSAGES/messages.mo b/ihatemoney/translations/zh_Hans/LC_MESSAGES/messages.mo deleted file mode 100644 index 0dcc89dd..00000000 Binary files a/ihatemoney/translations/zh_Hans/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/pyproject.toml b/pyproject.toml index d14e8288..bf2de70b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [build-system] -requires = ["setuptools", "setuptools-scm"] -build-backend = "setuptools.build_meta" +requires = ["hatchling"] +build-backend = "hatchling.build" [project] name = "ihatemoney" @@ -85,5 +85,19 @@ doc = [ [project.scripts] ihatemoney = "ihatemoney.manage:cli" -[tool.setuptools] -packages = ["ihatemoney"] +[tool.hatch.build.hooks.custom] +dependencies = [ + # Babel is needed to compile translations catalogs at package build time + "Babel>=2.13.1" +] + +[tool.hatch.build] +artifacts = ["ihatemoney/translations/**/*.mo"] +include = [ + "ihatemoney/", + "LICENSE", + "CONTRIBUTORS", + "CHANGELOG.md", + "README.md", + "SECURITY.md", +] diff --git a/tox.ini b/tox.ini index 695d550c..fe2c9ad9 100644 --- a/tox.ini +++ b/tox.ini @@ -1,4 +1,5 @@ [tox] +isolated_build = true envlist = py312,py311,py310,py39,py38,py37,lint_docs skip_missing_interpreters = True