aboutsummaryrefslogtreecommitdiff
path: root/justfile
diff options
context:
space:
mode:
authorDaniel Schadt <kingdread@gmx.de>2022-12-10 16:49:18 +0100
committerDaniel Schadt <kingdread@gmx.de>2022-12-10 16:49:18 +0100
commitc86100cd0ca4bf74597be4f4d34eaceae748aba5 (patch)
tree0450be27fdd4ad6fd81e716508c66e76d384c97c /justfile
parent0130f540ffefac371910a05cf52f30ac3bf06b5b (diff)
parent07512ee824c5d453cf32b7cb0fea83973f40dd0c (diff)
downloadfietsboek-c86100cd0ca4bf74597be4f4d34eaceae748aba5.tar.gz
fietsboek-c86100cd0ca4bf74597be4f4d34eaceae748aba5.tar.bz2
fietsboek-c86100cd0ca4bf74597be4f4d34eaceae748aba5.zip
Merge branch 'external-languages'
Diffstat (limited to 'justfile')
-rw-r--r--justfile60
1 files changed, 60 insertions, 0 deletions
diff --git a/justfile b/justfile
new file mode 100644
index 0000000..fc29e00
--- /dev/null
+++ b/justfile
@@ -0,0 +1,60 @@
+_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"
+
+# Initializes a new built-in language
+init-language locale:
+ pybabel init -d fietsboek/locale -l {{ locale }} -i fietsboek/locale/fietslog.pot
+ cp -r fietsboek/locale/en/html fietsboek/locale/{{ locale }}/
+
+# Update the built-in message catalogue
+update-language locale:
+ pybabel update -d fietsboek/locale -l {{ locale }} -i fietsboek/locale/fietslog.pot
+
+# Compile the given built-in language
+compile-language locale:
+ pybabel compile -d fietsboek/locale -l {{ locale }} -i fietsboek/locale/{{ locale }}/LC_MESSAGES/messages.po
+
+# Extract new messages from the source files
+extract-messages:
+ pybabel extract -F babel.cfg -o fietsboek/locale/fietslog.pot --input-dirs=fietsboek