From 4377c4fe19ebe373da2a8d77fa2d75f12ca3dc17 Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Tue, 8 Mar 2022 19:07:20 +0100 Subject: [PATCH] po: merge translations for metainfo file When installing the module, instead of copying the metainfo file to the destination, merge the available translations for it. Since this is done at install time, add gettext as BuildRequires for the RPM packaging; add libappstream-glib-devel as well only on RHEL/CentOS 8, since it contains the metainfo.its for gettext in order to handle .metainfo.xml files. This requires a LINGUAS file with the list of translations currently available: this is the way msgfmt picks the available languages to merge. Generate it dynamically from the list of available .po files. --- .gitignore | 1 + Makefile | 10 ++++++++-- packaging/cockpit-starter-kit.spec.in | 4 ++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 0eebb31..e45fe25 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ src/lib/ *.pot POTFILES* tmp/ +/po/LINGUAS diff --git a/Makefile b/Makefile index 37defb7..7b3b841 100644 --- a/Makefile +++ b/Makefile @@ -46,6 +46,9 @@ po/$(PACKAGE_NAME).metainfo.pot: org.cockpit-project.$(PACKAGE_NAME).metainfo.xm po/$(PACKAGE_NAME).pot: po/$(PACKAGE_NAME).html.pot po/$(PACKAGE_NAME).js.pot po/$(PACKAGE_NAME).manifest.pot po/$(PACKAGE_NAME).metainfo.pot msgcat --sort-output --output-file=$@ $^ +po/LINGUAS: + echo $(LINGUAS) | tr ' ' '\n' > $@ + # Update translations against current PO template update-po: po/$(PACKAGE_NAME).pot for lang in $(LINGUAS); do \ @@ -68,12 +71,15 @@ watch: clean: rm -rf dist/ rm -f $(SPEC) + rm -f po/LINGUAS -install: $(WEBPACK_TEST) +install: $(WEBPACK_TEST) po/LINGUAS mkdir -p $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME) cp -r dist/* $(DESTDIR)/usr/share/cockpit/$(PACKAGE_NAME) mkdir -p $(DESTDIR)/usr/share/metainfo/ - cp org.cockpit-project.$(PACKAGE_NAME).metainfo.xml $(DESTDIR)/usr/share/metainfo/ + msgfmt --xml -d po \ + --template org.cockpit-project.$(PACKAGE_NAME).metainfo.xml \ + -o $(DESTDIR)/usr/share/metainfo/org.cockpit-project.$(PACKAGE_NAME).metainfo.xml # this requires a built source tree and avoids having to install anything system-wide devel-install: $(WEBPACK_TEST) diff --git a/packaging/cockpit-starter-kit.spec.in b/packaging/cockpit-starter-kit.spec.in index 7a0093c..8afadd9 100644 --- a/packaging/cockpit-starter-kit.spec.in +++ b/packaging/cockpit-starter-kit.spec.in @@ -10,6 +10,10 @@ BuildArch: noarch BuildRequires: nodejs BuildRequires: make BuildRequires: libappstream-glib +BuildRequires: gettext +%if 0%{?rhel} && 0%{?rhel} <= 8 +BuildRequires: libappstream-glib-devel +%endif Requires: cockpit-system