aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2022-12-03 18:02:18 +0100
committerDaniel Schadt <kingdread@gmx.de>2022-12-06 18:39:20 +0100
commitb9628678de72793e1bf0ad10f8c842c5bcb7dc10 (patch)
tree671ecc697cfb40783745729a32dc8aa914196c23
parent191ebd7f707552029c6666cdb7f5bd16e5f491f3 (diff)
downloadfietsboek-b9628678de72793e1bf0ad10f8c842c5bcb7dc10.tar.gz
fietsboek-b9628678de72793e1bf0ad10f8c842c5bcb7dc10.tar.bz2
fietsboek-b9628678de72793e1bf0ad10f8c842c5bcb7dc10.zip
add justfile for language pack processing
-rw-r--r--.gitignore1
-rw-r--r--doc/developer/language-pack.rst17
-rw-r--r--justfile43
3 files changed, 61 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index a3cbe22..259f717 100644
--- a/.gitignore
+++ b/.gitignore
@@ -24,3 +24,4 @@ test
.venv/
/data
poetry.toml
+/language-packs
diff --git a/doc/developer/language-pack.rst b/doc/developer/language-pack.rst
index a39617b..71cf9e8 100644
--- a/doc/developer/language-pack.rst
+++ b/doc/developer/language-pack.rst
@@ -119,5 +119,22 @@ And enable it in your settings:
available_locales = en nl
+Automation
+----------
+
+If you are fine with the following default values, then you can use the
+provided :file:`justfile` with just_ to automate most of the boring processes:
+
+* Poetry will be used
+* The pack will be saved in :file:`language-packs/fietsboek-i18n-LOCALE`
+* The module name will be ``fietsboek_i18n_LOCALE``
+
+.. code-block:: bash
+
+ just create-language-pack nl
+ just update-language-pack nl
+ just compile-language-pack nl
+
.. _Poetry: https://python-poetry.org/
.. _Babel: https://babel.pocoo.org/en/latest/index.html
+.. _just: https://github.com/casey/just
diff --git a/justfile b/justfile
new file mode 100644
index 0000000..e5625fc
--- /dev/null
+++ b/justfile
@@ -0,0 +1,43 @@
+default:
+ @just --list
+
+# Create a new language pack
+create-language-pack locale:
+ #!/bin/bash
+ set -euo pipefail
+ [ -e "language-packs/fietsboek-i18n-{{ locale }}" ] && (echo "Already exists!" ; exit 1)
+ FB_PATH="$PWD"
+ mkdir -p "language-packs/fietsboek-i18n-{{ locale }}"
+ cd "language-packs/fietsboek-i18n-{{ locale }}"
+ {
+ echo '[tool.poetry]'
+ echo 'name = "fietsboek-i18n-{{ locale }}"'
+ echo 'version = "0.1.0"'
+ echo 'description = ""'
+ echo 'authors = ["John Doe <john@example.com>"]'
+ echo 'packages = [{include = "fietsboek_i18n_{{ locale }}"}]'
+ echo '[tool.poetry.dependencies]'
+ echo 'python = "^3.7"'
+ echo '[build-system]'
+ echo 'requires = ["poetry-core"]'
+ echo 'build-backend = "poetry.core.masonry.api"'
+ } >> pyproject.toml
+ mkdir -p "fietsboek_i18n_{{ locale }}/locale"
+ touch "fietsboek_i18n_{{ locale }}/__init__.py"
+ cp -r "$FB_PATH/fietsboek/locale/en/html" "fietsboek_i18n_{{ locale }}/locale/"
+ pybabel init -d "fietsboek_i18n_{{ locale }}/locale" -l {{ locale }} -i "$FB_PATH/fietsboek/locale/fietslog.pot"
+
+# Compile the messages of an existing language pack
+compile-language-pack locale:
+ #!/bin/bash
+ set -euo pipefail
+ cd "language-packs/fietsboek-i18n-{{ locale }}"
+ pybabel compile -d "fietsboek_i18n_{{ locale }}/locale" -l {{ locale }} -i "fietsboek_i18n_{{ locale }}/locale//{{ locale }}/LC_MESSAGES/messages.po"
+
+# Update the messages contained in the given pack
+update-language-pack locale:
+ #!/bin/bash
+ set -euo pipefail
+ FB_PATH="$PWD"
+ cd "language-packs/fietsboek-i18n-{{ locale }}"
+ pybabel update -d "fietsboek_i18n_{{ locale }}/locale" -l {{ locale }} -i "$FB_PATH/fietsboek/locale/fietslog.pot"