From 8d1044fc0e955c44519f945e81f74a19377eb549 Mon Sep 17 00:00:00 2001
From: Dominik George <dominik.george@teckids.org>
Date: Tue, 17 Aug 2021 23:37:55 +0200
Subject: [PATCH] Add Makefile for compiling messages

---
 .gitlab-ci.yml | 10 ++++------
 Makefile       | 13 +++++++++++++
 2 files changed, 17 insertions(+), 6 deletions(-)
 create mode 100644 Makefile

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 25b29a4..74fd540 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -13,16 +13,14 @@ build_dist:
   interruptible: true
   stage: build
   before_script:
-    - pip3 install poetry tox
-    - apt update
-    - apt install sudo
-    - id testuser || adduser --disabled-password --gecos "Test User" testuser
-    - chown -R testuser .
+    - pip3 install poetry babel
+    - apt -y update
+    - apt -y install make
   script:
     - if ! [ x$CI_COMMIT_REF_NAME = x$CI_COMMIT_TAG ]; then
         poetry version $(poetry version | cut -d" " -f2)+$(date --date=${CI_COMMIT_TIMESTAMP} +%Y%m%d%H%M%S);
       fi
-    - sudo -u testuser poetry build
+    - make dist
   artifacts:
     paths:
       - dist/
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..1723a9b
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,13 @@
+messages.pot: pelican_theme_teckids/templates/*.html babel.cfg
+	pybabel extract --mapping babel.cfg --output messages.pot
+
+pelican_theme_teckids/translations/en/LC_MESSAGES/messages.po: messages.pot
+	pybabel update --input-file messages.pot --output-dir pelican_theme_teckids/translations/ --locale en --domain messages
+
+pelican_theme_teckids/translations/en/LC_MESSAGES/messages.mo: pelican_theme_teckids/translations/en/LC_MESSAGES/messages.po
+	pybabel compile --directory pelican_theme_teckids/translations/ --domain messages
+
+dist: pelican_theme_teckids/translations/en/LC_MESSAGES/messages.mo
+	poetry build
+
+.PHONY: dist
-- 
GitLab