From 416c32f85b94a6f784e9ca3da95d0ee8869f48d3 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Tue, 15 Oct 2019 12:28:36 +0200 Subject: [PATCH] ws, bridge: Move AppStream metadata and polkit i18n from intltool to gettext intltool has been deprecated for a while [1], in favor of gettext being able to handle XML and other files natively. Use xgettext/msgfmt for extracting/merging translations of our AppStream metadata and polkit policy. Use W3C ITS [2] files instead of the intltool-specific `<_tag>` format. gettext ships appstream ITS files by default; copy the polkit ones from gettext 0.20 for now to avoid having to build-depend on policykit-1 just for these on Debian/Ubuntu. This avoids having to build intermediate files, copy the original files around, and keep their format valid (without mutilated tags). It also drops the intltool dependency. Add an explicit gettext build dependency (which previously was transitive through intltool). This also drops the post-processing seddery of the polkit file; msgfmt does the right thing wrt. handling the `gettext-domain=` attribute. [1] https://wiki.gnome.org/MigratingFromIntltoolToGettext [2] https://www.w3.org/TR/its/#trans-datacat Closes #12979 --- .gitignore | 1 - .travis.yml | 2 +- configure.ac | 13 ---------- containers/unit-tests/setup.sh | 2 +- po/Makefile.am | 24 +++++++++++-------- po/its/polkit.its | 8 +++++++ po/its/polkit.loc | 6 +++++ src/bridge/Makefile.am | 9 +------ ...g.cockpit-project.cockpit-bridge.policy.in | 4 ++-- src/ws/Makefile-ws.am | 8 +------ src/ws/cockpit.appdata.xml.in | 14 +++++------ tools/cockpit.spec | 2 +- tools/debian/control | 2 +- 13 files changed, 43 insertions(+), 52 deletions(-) create mode 100644 po/its/polkit.its create mode 100644 po/its/polkit.loc diff --git a/.gitignore b/.gitignore index 21e4ed475..1533c995b 100644 --- a/.gitignore +++ b/.gitignore @@ -112,7 +112,6 @@ depcomp /src/ws/cockpit-tempfiles.conf src/common/cockpitassets.c src/common/cockpitassets.h -/po/.intltool-merge-cache !/test-avocado /test-avocado/lib/var.env /test-avocado/lib/var.envc diff --git a/.travis.yml b/.travis.yml index b592f1a1b..5bad5d816 100644 --- a/.travis.yml +++ b/.travis.yml @@ -34,7 +34,7 @@ addons: - git - glib-networking - gtk-doc-tools - - intltool + - gettext - libfontconfig1 - libglib2.0-dev - libgudev-1.0-dev diff --git a/configure.ac b/configure.ac index 4785f73c4..a12f268ce 100644 --- a/configure.ac +++ b/configure.ac @@ -261,19 +261,6 @@ else AC_MSG_ERROR([no. Please install gettext tools]) fi -AC_PATH_PROG(INTLTOOL_EXTRACT, intltool-extract) -AC_PATH_PROG(INTLTOOL_MERGE, intltool-merge) -AC_PATH_PROG(INTLTOOL_UPDATE, intltool-update) -AC_MSG_CHECKING(for intltool binaries) -if test -x "$INTLTOOL_EXTRACT" -a -x "$INTLTOOL_MERGE" -a -x "$INTLTOOL_UPDATE"; then - AC_SUBST(INTLTOOL_EXTRACT) - AC_SUBST(INTLTOOL_MERGE) - AC_SUBST(INTLTOOL_UPDATE) - AC_MSG_RESULT(yes) -else - AC_MSG_ERROR(no. Please install intltool package) -fi - # go AC_PATH_PROG([GOLANG], [go]) diff --git a/containers/unit-tests/setup.sh b/containers/unit-tests/setup.sh index 8e6a39c62..cb6d1f20c 100755 --- a/containers/unit-tests/setup.sh +++ b/containers/unit-tests/setup.sh @@ -17,7 +17,7 @@ dependencies="\ glib-networking \ glib-networking-dbgsym\ gtk-doc-tools \ - intltool \ + gettext \ libc6-dbg \ libfontconfig1 \ libglib2.0-0-dbgsym \ diff --git a/po/Makefile.am b/po/Makefile.am index 78ccdb46c..9488b0eca 100644 --- a/po/Makefile.am +++ b/po/Makefile.am @@ -49,6 +49,7 @@ uninstall-local:: # General code packages to translate TRANSLATE = \ pkg/ \ + src/bridge/ \ src/ws/ \ $(NULL) @@ -65,10 +66,11 @@ po/POTFILES.js.in: po/POTFILES.manifest.in: $(MKDIR_P) $(notdir $@) ( cd $(srcdir) && find $(TRANSLATE) -name 'manifest.json.in' ) > $@ -po/POTFILES.pre.in: prepare-po - $(MKDIR_P) $(notdir $@) - ( cd tmp/ && find . -type f ) > $@ -.PHONY: po/POTFILES.c.in po/POTFILES.html.in po/POTFILES.js.in po/POTFILES.manifest.in po/POTFILES.pre.in +po/POTFILES.appstream.in: + ( cd $(srcdir) && find $(TRANSLATE) -name '*.appdata.xml.in' ) > $@ +po/POTFILES.polkit.in: + ( cd $(srcdir) && find $(TRANSLATE) -name '*.policy.in' ) > $@ +.PHONY: po/POTFILES.c.in po/POTFILES.html.in po/POTFILES.js.in po/POTFILES.manifest.in po/POTFILES.appstream.in po/POTFILES.polkit.in # Extract from GLib based C code files po/cockpit.c.pot: po/POTFILES.c.in @@ -96,14 +98,14 @@ po/cockpit.js.pot: po/POTFILES.js.in po/cockpit.manifest.pot: po/POTFILES.manifest.in $(srcdir)/tools/missing $(srcdir)/po/manifest2po -d $(srcdir) -f $^ -o $@ -# Extract pre-processed prepare-po data in tmp/ -po/cockpit.pre.pot: po/POTFILES.pre.in - $(XGETTEXT) --default-domain=cockpit --output=$@ \ - --language=C --keyword=N_ \ - --from-code=UTF-8 --directory=$(builddir)/tmp --files-from=$^ +po/cockpit.appstream.pot: po/POTFILES.appstream.in + $(XGETTEXT) --output=$@ --files-from=$^ + +po/cockpit.polkit.pot: po/POTFILES.polkit.in + GETTEXTDATADIRS=$(srcdir)/po $(XGETTEXT) --output=$@ --files-from=$^ # Combine the above pot files into one -po/cockpit.pot: po/cockpit.c.pot po/cockpit.html.pot po/cockpit.js.pot po/cockpit.manifest.pot po/cockpit.pre.pot +po/cockpit.pot: po/cockpit.c.pot po/cockpit.html.pot po/cockpit.js.pot po/cockpit.manifest.pot po/cockpit.appstream.pot po/cockpit.polkit.pot $(MSGCAT) --sort-output --output-file=$@ $^ # Actually update the old translations with new translatable text @@ -146,4 +148,6 @@ EXTRA_DIST += \ po/po.empty.js \ po/po2json \ po/zanata.xml \ + po/its/polkit.its \ + po/its/polkit.loc \ $(NULL) diff --git a/po/its/polkit.its b/po/its/polkit.its new file mode 100644 index 000000000..1c37e6bee --- /dev/null +++ b/po/its/polkit.its @@ -0,0 +1,8 @@ + + + + + diff --git a/po/its/polkit.loc b/po/its/polkit.loc new file mode 100644 index 000000000..c7427ec67 --- /dev/null +++ b/po/its/polkit.loc @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/bridge/Makefile.am b/src/bridge/Makefile.am index b8af8c854..e7e52563d 100644 --- a/src/bridge/Makefile.am +++ b/src/bridge/Makefile.am @@ -260,19 +260,12 @@ polkitdir = $(datadir)/polkit-1/actions polkit_in_files = src/bridge/org.cockpit-project.cockpit-bridge.policy.in polkit_DATA = $(polkit_in_files:.policy.in=.policy) -# gettext-domain= must only occur on C strings, not translated ones %.policy: %.policy.in $(PO_FILES) - $(AM_V_GEN) $(INTLTOOL_MERGE) -q -x $(top_srcdir)/po $< - | sed '/xml:lang=/ s/\ gettext-domain=".*"//' > $@ + GETTEXTDATADIRS=$(srcdir)/po $(MSGFMT) --xml -d $(top_srcdir)/po --template $< --output $@ EXTRA_DIST += $(polkit_in_files) CLEANFILES += $(polkit_DATA) -prepare-po-bridge-policy: $(polkit_in_files) - cp $< . - $(AM_V_GEN) $(INTLTOOL_EXTRACT) -l --type=gettext/xml $(notdir $<) - -prepare-po:: prepare-po-bridge-policy - # ----------------------------------------------------------------------------- # PCP diff --git a/src/bridge/org.cockpit-project.cockpit-bridge.policy.in b/src/bridge/org.cockpit-project.cockpit-bridge.policy.in index 38bcb8c99..8267f3b75 100644 --- a/src/bridge/org.cockpit-project.cockpit-bridge.policy.in +++ b/src/bridge/org.cockpit-project.cockpit-bridge.policy.in @@ -7,8 +7,8 @@ https://www.cockpit-project.org - <_description gettext-domain="cockpit">Administration with Cockpit Web Console - <_message gettext-domain="cockpit">Authentication is required to perform privileged tasks with the Cockpit Web Console + Administration with Cockpit Web Console + Authentication is required to perform privileged tasks with the Cockpit Web Console auth_admin auth_admin diff --git a/src/ws/Makefile-ws.am b/src/ws/Makefile-ws.am index d7d989641..be98fd7bb 100644 --- a/src/ws/Makefile-ws.am +++ b/src/ws/Makefile-ws.am @@ -239,7 +239,7 @@ nodist_appdata_DATA = src/ws/cockpit.appdata.xml appdata_in = src/ws/cockpit.appdata.xml.in $(nodist_appdata_DATA): $(appdata_in) $(PO_FILES) - $(AM_V_GEN) LC_ALL=C $(INTLTOOL_MERGE) -q -x -u $(top_srcdir)/po $< $@ + $(AM_V_GEN) $(MSGFMT) --xml -d $(top_srcdir)/po --template $< --output $@ pixmapdir = $(datadir)/pixmaps pixmap_DATA = src/ws/cockpit.png @@ -459,9 +459,3 @@ install-tests:: install-exec-hook:: mkdir -p $(DESTDIR)$(sysconfdir)/cockpit/ws-certs.d $(DESTDIR)$(sysconfdir)/cockpit/machines.d chmod 755 $(DESTDIR)$(sysconfdir)/cockpit/ws-certs.d $(DESTDIR)$(sysconfdir)/cockpit/machines.d - -prepare-po-appdata: $(appdata_in) - cp $< . - $(INTLTOOL_EXTRACT) -l --type=gettext/xml $(notdir $(appdata_in)) - -prepare-po:: prepare-po-appdata diff --git a/src/ws/cockpit.appdata.xml.in b/src/ws/cockpit.appdata.xml.in index addc1c068..613d5890a 100644 --- a/src/ws/cockpit.appdata.xml.in +++ b/src/ws/cockpit.appdata.xml.in @@ -5,27 +5,27 @@ CC0-1.0 LGPL-2.0+ Cockpit - <_summary>Web Console for Linux servers + Web Console for Linux servers - <_p> +

Cockpit is a server manager that makes it easy to administer your Linux servers via a web browser. Jumping between the terminal and the web tool is no problem. A service started via Cockpit can be stopped via the terminal. Likewise, if an error occurs in the terminal, it can be seen in the Cockpit journal interface. - - <_p> +

+

Cockpit is perfect for new sysadmins, allowing them to easily perform simple tasks such as storage administration, inspecting journals and starting and stopping services. You can monitor and administer several servers at the same time. Just add them with a single click and your machines will look after its buddies. - - <_p> +

+

Once Cockpit is installed, enable it with "systemctl enable --now cockpit.socket". - +

System diff --git a/tools/cockpit.spec b/tools/cockpit.spec index f151c6a32..329f2b0e1 100644 --- a/tools/cockpit.spec +++ b/tools/cockpit.spec @@ -70,7 +70,7 @@ BuildRequires: pam-devel BuildRequires: autoconf automake BuildRequires: /usr/bin/python3 -BuildRequires: intltool +BuildRequires: gettext >= 0.19.7 %if %{defined build_dashboard} BuildRequires: libssh-devel >= 0.7.1 %endif diff --git a/tools/debian/control b/tools/debian/control index eb1f78356..ee710c034 100644 --- a/tools/debian/control +++ b/tools/debian/control @@ -4,7 +4,7 @@ Priority: optional Maintainer: Cockpit Build-Depends: debhelper (>= 10), dpkg-dev (>= 1.17.14), - intltool, + gettext (>= 0.19.7), libssh-dev, zlib1g-dev, libkrb5-dev (>= 1.11),