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.
This commit is contained in:
Pino Toscano 2022-03-08 19:07:20 +01:00 committed by Martin Pitt
parent b5969c1c9b
commit 4377c4fe19
3 changed files with 13 additions and 2 deletions

View file

@ -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)