From 15ba1ac229e382b79a680ac0e4b12d2ddd23ed6e Mon Sep 17 00:00:00 2001
From: Benny Baumann <BenBE@geshi.org>
Date: Fri, 27 Sep 2019 00:55:52 +0200
Subject: [PATCH] chg: Use templating magic to generate rules to create .po
 files for each language

---
 Makefile | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/Makefile b/Makefile
index 96b331c..70dca34 100644
--- a/Makefile
+++ b/Makefile
@@ -78,12 +78,11 @@ ${POTDIR}/%.pot: ${SRCDIR}/%.c
 ${POTDIR}/%.pot: ${SRCDIR}/%.cpp
 	${MKDIR} ${@D} && ${XGETTEXT} ${XGETTEXT_FLAGS} $( [ -r $@ ] && echo -- -j ) -o $@ $<
 
-$(foreach POFILE,${POLANGS},${PODIR}/${POFILE}/%.po): ${POTDIR}/%.pot
-	for POLANG in ${POLANGS}; do \
-		${MKDIR} ${PODIR}/$${POLANG}/${*D} && \
-		( [ ! -r ${PODIR}/$${POLANG}/$*.po ] && ${MSGINIT} --no-translator --input=${POTDIR}/$*.pot --locale=${POLANG} --output=${PODIR}/$${POLANG}/$*.po ) && \
-		( ${MSGMERGE} --update ${PODIR}/$${POLANG}/$*.po ${POTDIR}/$*.pot ) \
-	done
+define genlangporules
+${PODIR}/$(1)/%.po: ${POTDIR}/%.pot
+	$${MKDIR} $${@D} && ( [ -r $$< ] && $${MSGINIT} --no-translator --input=$$< --locale=$$(patsubst $${PODIR}/%/$$(patsubst $${POTDIR}/%.pot,%.po,$$<),%,$$@) --output=$$@ ) && ( $${MSGMERGE} --update $$@ $$< )
+endef
+$(foreach POLANG,${POLANGS},$(eval $(call genlangporules,$${POLANG})))
 
 ${MODIR}/%.mo: ${PODIR}/%.po
 	${MKDIR} ${@D} && ${MSGFMT} --output-file=$@ $<
-- 
GitLab