From b9628678de72793e1bf0ad10f8c842c5bcb7dc10 Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 3 Dec 2022 18:02:18 +0100 Subject: add justfile for language pack processing --- justfile | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 justfile (limited to 'justfile') 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 "]' + 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" -- cgit v1.2.3 From acce7c38d3833b59c4eb2e99dbe7f0393b6a9cbd Mon Sep 17 00:00:00 2001 From: Daniel Schadt Date: Sat, 3 Dec 2022 18:56:32 +0100 Subject: replace Makefile targets with justfile We might re-introduce Makefiles, but for different purposes (SASS or TypeScript compilation). --- justfile | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'justfile') diff --git a/justfile b/justfile index e5625fc..fc29e00 100644 --- a/justfile +++ b/justfile @@ -1,4 +1,4 @@ -default: +_default: @just --list # Create a new language pack @@ -41,3 +41,20 @@ update-language-pack locale: 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 -- cgit v1.2.3