diff --git a/.gitignore b/.gitignore index 62608c2bd..fcd0fd32a 100644 --- a/.gitignore +++ b/.gitignore @@ -31,4 +31,5 @@ elmd-conn.json tests/bitcoin tests/bitcoin.binary tests/bitcoin.compile -token.sh \ No newline at end of file +token.sh +src/cryptoadvance/specter/translations/**/messages.mo \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index de6bf6af9..5390690a1 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -54,6 +54,7 @@ check: - pip3 install -r requirements.txt - pip3 install -e . - pip3 install -r test_requirements.txt + - python3 setup.py install # compiles babel stuff as well (might make pip install obsolete) # pytest --docker not working? Uncomment this for better debugging: # - python3 tests/conftest.py - py.test --cov-report term --cov cryptoadvance --docker @@ -65,6 +66,7 @@ check: # start the server in the background - pip3 install -e . - pip3 install -r test_requirements.txt + - python3 setup.py install # compiles babel stuff as well (might make pip install obsolete) - npm i - ./utils/test-cypress.sh --docker --debug run - docker ps || echo "probably no docker available anyway" diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 49551cab1..f1f8cd6c0 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -76,6 +76,7 @@ virtualenv --python=python3 .env source .env/bin/activate pip3 install -r requirements.txt --require-hashes pip3 install -e . +python3 setup.py install # also compiles the babel translation-files ``` _note: invoking commands in the Windows PowerShell is slightly different:_ diff --git a/MANIFEST.in b/MANIFEST.in index 5163bdb63..0531cc4b6 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,4 @@ recursive-include src/cryptoadvance/specter/templates * recursive-include src/cryptoadvance/specter/static * +recursive-include src/cryptoadvance/specter/translations/*/LC_MESSAGES *.mo include requirements.txt diff --git a/babel/README.md b/babel/README.md index a889ffcdc..2bd1715c9 100644 --- a/babel/README.md +++ b/babel/README.md @@ -176,3 +176,18 @@ The only other step is to add the new language to the LANGUAGES list in `config. # right: "he": "עברית", ``` + +## For Packagers: +The mo-files are not checked into the repository as (large) binary (large) objects ("BLOBs") should not be checked into git to reduce repo-size bloat. So effectively they need to be generated before the user is using the software. Effectively what has been described above: + +``` +pybabel compile -d src/cryptoadvance/specter/translations +``` + +In order to make that as transparent as possible, that procedure has been integrated into the setup-process. So it will be executed by: + +``` +python3 setup.py install +``` + +Unfortunately, it won't be executed by `pip3 install -e .` even though that has been propagated very long to be the developement-env installation procedure. So in the various installation procedures (mainly in `.gitlab-ci.yml`) this has been changed. For more special packaging mechanism, this needs to be respected as well. \ No newline at end of file diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 000000000..b5c347ce0 --- /dev/null +++ b/setup.cfg @@ -0,0 +1,3 @@ +[compile_catalog] +directory=src/cryptoadvance/specter/translations +domain=messages \ No newline at end of file diff --git a/setup.py b/setup.py old mode 100644 new mode 100755 index cc6150587..c5c70d552 --- a/setup.py +++ b/setup.py @@ -1,11 +1,30 @@ +from babel.messages import frontend as babel from glob import glob from setuptools import find_namespace_packages, setup +from setuptools.command.install import install + + +class InstallWithBabelCompile(install): + """from this stackoverflow question + https://stackoverflow.com/questions/40051076/compile-translation-files-when-calling-setup-py-install + """ + + def run(self): + from babel.messages.frontend import compile_catalog + + compiler = compile_catalog(self.distribution) + option_dict = self.distribution.get_option_dict("compile_catalog") + compiler.domain = [option_dict["domain"][1]] + compiler.directory = option_dict["directory"][1] + compiler.run() + super().run() + + with open("requirements.txt") as f: install_reqs = f.read().strip().split("\n") - # Filter out comments/hashes reqs = [] for req in install_reqs: @@ -28,6 +47,11 @@ setup( url="https://github.com/cryptoadvance/specter-desktop", packages=find_namespace_packages("src", include=["cryptoadvance.*"]), package_dir={"": "src"}, + package_data={ + "": [ + "translations/*/LC_MESSAGES/messages.mo", + ] + }, # take METADATA.in into account, include that stuff as well (static/templates) include_package_data=True, install_requires=reqs, @@ -38,4 +62,12 @@ setup( "Framework :: Flask", ], python_requires=">=3.6,<3.10", + cmdclass={ + "install": InstallWithBabelCompile, + # The rest is convenience but not strictly necessary for the automation: + "compile_catalog": babel.compile_catalog, + "extract_messages": babel.extract_messages, + "init_catalog": babel.init_catalog, + "update_catalog": babel.update_catalog, + }, ) diff --git a/src/cryptoadvance/specter/translations/bg/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/bg/LC_MESSAGES/messages.mo deleted file mode 100644 index ea2d951ba..000000000 Binary files a/src/cryptoadvance/specter/translations/bg/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/de/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/de/LC_MESSAGES/messages.mo deleted file mode 100644 index 5fd5433a5..000000000 Binary files a/src/cryptoadvance/specter/translations/de/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/el/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/el/LC_MESSAGES/messages.mo deleted file mode 100644 index a03ae3c68..000000000 Binary files a/src/cryptoadvance/specter/translations/el/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/es/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/es/LC_MESSAGES/messages.mo deleted file mode 100644 index 30ccc8970..000000000 Binary files a/src/cryptoadvance/specter/translations/es/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/fi/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/fi/LC_MESSAGES/messages.mo deleted file mode 100644 index 734e1dcee..000000000 Binary files a/src/cryptoadvance/specter/translations/fi/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/fr/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/fr/LC_MESSAGES/messages.mo deleted file mode 100644 index cb0d2a0b1..000000000 Binary files a/src/cryptoadvance/specter/translations/fr/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/he/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/he/LC_MESSAGES/messages.mo deleted file mode 100644 index ab296903b..000000000 Binary files a/src/cryptoadvance/specter/translations/he/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/hi/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/hi/LC_MESSAGES/messages.mo deleted file mode 100644 index 1a0036724..000000000 Binary files a/src/cryptoadvance/specter/translations/hi/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/hr/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/hr/LC_MESSAGES/messages.mo deleted file mode 100644 index 6abfe8806..000000000 Binary files a/src/cryptoadvance/specter/translations/hr/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/is/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/is/LC_MESSAGES/messages.mo deleted file mode 100644 index d7b9226e0..000000000 Binary files a/src/cryptoadvance/specter/translations/is/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/it/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/it/LC_MESSAGES/messages.mo deleted file mode 100644 index 42ca97324..000000000 Binary files a/src/cryptoadvance/specter/translations/it/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/ko/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/ko/LC_MESSAGES/messages.mo deleted file mode 100644 index 5f074547d..000000000 Binary files a/src/cryptoadvance/specter/translations/ko/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/mal/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/mal/LC_MESSAGES/messages.mo deleted file mode 100644 index 1f0cc024a..000000000 Binary files a/src/cryptoadvance/specter/translations/mal/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/nl/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/nl/LC_MESSAGES/messages.mo deleted file mode 100644 index c8dc2202f..000000000 Binary files a/src/cryptoadvance/specter/translations/nl/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/pl/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/pl/LC_MESSAGES/messages.mo deleted file mode 100644 index 4902cf229..000000000 Binary files a/src/cryptoadvance/specter/translations/pl/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/pt/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/pt/LC_MESSAGES/messages.mo deleted file mode 100644 index 245ae36c1..000000000 Binary files a/src/cryptoadvance/specter/translations/pt/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/ru/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/ru/LC_MESSAGES/messages.mo deleted file mode 100644 index 34b404af2..000000000 Binary files a/src/cryptoadvance/specter/translations/ru/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/sr/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/sr/LC_MESSAGES/messages.mo deleted file mode 100644 index 3450b884d..000000000 Binary files a/src/cryptoadvance/specter/translations/sr/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/sv/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/sv/LC_MESSAGES/messages.mo deleted file mode 100644 index bfe427c18..000000000 Binary files a/src/cryptoadvance/specter/translations/sv/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/ta/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/ta/LC_MESSAGES/messages.mo deleted file mode 100644 index 7ba107dd6..000000000 Binary files a/src/cryptoadvance/specter/translations/ta/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/tr/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/tr/LC_MESSAGES/messages.mo deleted file mode 100644 index 975772187..000000000 Binary files a/src/cryptoadvance/specter/translations/tr/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/zh_Hans_CN/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/zh_Hans_CN/LC_MESSAGES/messages.mo deleted file mode 100644 index 5c114eb53..000000000 Binary files a/src/cryptoadvance/specter/translations/zh_Hans_CN/LC_MESSAGES/messages.mo and /dev/null differ diff --git a/src/cryptoadvance/specter/translations/zh_Hant_TW/LC_MESSAGES/messages.mo b/src/cryptoadvance/specter/translations/zh_Hant_TW/LC_MESSAGES/messages.mo deleted file mode 100644 index 0465b0759..000000000 Binary files a/src/cryptoadvance/specter/translations/zh_Hant_TW/LC_MESSAGES/messages.mo and /dev/null differ