[virt-tools-list] [virt-viewer PATCH 01/14] po: provide custom make rules for po file management
Daniel P. Berrangé
berrange at redhat.com
Wed Feb 20 17:50:52 UTC 2019
Historically we have relied on intltool to install a standard
po/Makefile.in.in which has very limited scope for customization.
intltool is deprecated in favour of standard gettextize tools,
but these share the same disadvantages.
Writing make rules for po file management is no more difficult
than any other rules libvirt-glib has, so stop using intltool
and don't use gettextize ether.
Signed-off-by: Daniel P. Berrangé <berrange at redhat.com>
---
Makefile.am | 7 --
autogen.sh | 1 -
configure.ac | 6 +-
data/Makefile.am | 12 +-
data/remote-viewer.appdata.xml.in | 12 +-
data/remote-viewer.desktop.in | 4 +-
...iewer-mime.xml.in => virt-viewer-mime.xml} | 0
m4/virt-nls.m4 | 45 ++++++++
mingw-virt-viewer.spec.in | 2 +-
po/Makefile.am | 105 ++++++++++++++++++
po/POTFILES | 26 +++++
po/POTFILES.in | 27 -----
po/README.md | 38 +++++++
po/lt.po | 2 +-
virt-viewer.spec.in | 2 +-
15 files changed, 234 insertions(+), 55 deletions(-)
rename data/{virt-viewer-mime.xml.in => virt-viewer-mime.xml} (100%)
create mode 100644 m4/virt-nls.m4
create mode 100644 po/Makefile.am
create mode 100644 po/POTFILES
delete mode 100644 po/POTFILES.in
create mode 100644 po/README.md
diff --git a/Makefile.am b/Makefile.am
index d33367a..4cfdd59 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,9 +8,6 @@ AM_DISTCHECK_CONFIGURE_FLAGS = --disable-update-mimedb
EXTRA_DIST = \
$(PACKAGE).spec $(PACKAGE).spec.in \
mingw-$(PACKAGE).spec.in \
- intltool-extract.in \
- intltool-merge.in \
- intltool-update.in \
GNUmakefile \
maint.mk \
cfg.mk \
@@ -24,9 +21,6 @@ EXTRA_DIST = \
DISTCLEAN_FILES = \
$(PACKAGE).spec \
mingw-$(PACKAGE).spec \
- intltool-extract \
- intltool-merge \
- intltool-update \
$(NULL)
MAINTAINERCLEANFILES = \
@@ -34,7 +28,6 @@ MAINTAINERCLEANFILES = \
$(srcdir)/INSTALL \
$(GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL) \
$(GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL) \
- $(srcdir)/m4/intltool.m4 \
$(NULL)
dist-hook: gen-ChangeLog gen-AUTHORS
diff --git a/autogen.sh b/autogen.sh
index b77ac33..9c8968f 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -29,7 +29,6 @@ touch ChangeLog AUTHORS
mkdir -p m4
autoreconf -vfi
-intltoolize --force
cd $THEDIR
diff --git a/configure.ac b/configure.ac
index 5598c61..a03d846 100644
--- a/configure.ac
+++ b/configure.ac
@@ -96,8 +96,8 @@ GETTEXT_PACKAGE=virt-viewer
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],"$GETTEXT_PACKAGE", [GETTEXT package name])
-AM_GLIB_GNU_GETTEXT
-IT_PROG_INTLTOOL([0.35.0])
+VIRT_VIEWER_ARG_NLS
+VIRT_VIEWER_CHECK_NLS
PKG_PROG_PKG_CONFIG
GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
@@ -261,7 +261,7 @@ AC_CONFIG_FILES([
icons/256x256/Makefile
man/Makefile
mingw-virt-viewer.spec
- po/Makefile.in
+ po/Makefile
src/Makefile
src/virt-viewer.rc
tests/Makefile
diff --git a/data/Makefile.am b/data/Makefile.am
index 1f6c8bf..0e50f3d 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -68,17 +68,17 @@ else #!WIN32
desktopdir = $(datadir)/applications
DESKTOPFILES = remote-viewer.desktop.in
desktop_DATA = $(DESKTOPFILES:.desktop.in=.desktop)
- at INTLTOOL_DESKTOP_RULE@
+%.desktop: %.desktop.in
+ $(AM_V_GEN)$(MSGFMT) --desktop --template $< -d $(top_srcdir)/po -o $@
-MIMEFILES = virt-viewer-mime.xml.in
mimedir = $(datadir)/mime/packages
mime_DATA = virt-viewer-mime.xml
- at INTLTOOL_XML_RULE@
appdatadir = $(datadir)/appdata
APPDATAFILES = remote-viewer.appdata.xml.in
appdata_DATA = $(APPDATAFILES:.xml.in=.xml)
- at INTLTOOL_XML_RULE@
+%.appdata.xml: %.appdata.xml.in
+ $(AM_V_GEN)$(MSGFMT) --xml --template $< -d $(top_srcdir)/po -o $@
install-data-hook:
if ENABLE_UPDATE_MIMEDB
@@ -92,8 +92,8 @@ if ENABLE_UPDATE_MIMEDB
$(UPDATE_MIME_DATABASE) "$(DESTDIR)$(datadir)/mime";
endif
-CLEANFILES += $(mime_DATA) $(desktop_DATA) $(appdata_DATA)
-EXTRA_DIST += $(MIMEFILES) $(DESKTOPFILES) $(APPDATAFILES)
+CLEANFILES += $(desktop_DATA) $(appdata_DATA)
+EXTRA_DIST += $(mime_DATA) $(DESKTOPFILES) $(APPDATAFILES)
endif
diff --git a/data/remote-viewer.appdata.xml.in b/data/remote-viewer.appdata.xml.in
index 3f6017d..53945f4 100644
--- a/data/remote-viewer.appdata.xml.in
+++ b/data/remote-viewer.appdata.xml.in
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
-<application>
+<component type="desktop">
<id type="desktop">remote-viewer.desktop</id>
<metadata_license>CC0-1.0</metadata_license>
<project_license>GPL-2.0+</project_license>
- <_name>Remote Viewer</_name>
- <_summary>Remotely access virtual machines</_summary>
+ <name>Remote Viewer</name>
+ <summary>Remotely access virtual machines</summary>
<description>
- <_p>
+ <p>
Remote Viewer provides a graphical viewer for the guest OS
display. At this time it supports guest OS using the VNC
or SPICE protocols. Further protocols may be supported in
the future as user demand dictates. The viewer can connect
directly to both local and remotely hosted guest OS, optionally
using SSL/TLS encryption.
- </_p>
+ </p>
</description>
<screenshots>
<screenshot type="default">https://virt-manager.org/appdata/en_US/virt-viewer/general.png</screenshot>
@@ -26,4 +26,4 @@
</provides>
<url type="homepage">https://virt-manager.org/</url>
<updatecontact>virt-tools-list_at_redhat.com</updatecontact>
-</application>
+</component>
diff --git a/data/remote-viewer.desktop.in b/data/remote-viewer.desktop.in
index 24bcf6a..eff137e 100644
--- a/data/remote-viewer.desktop.in
+++ b/data/remote-viewer.desktop.in
@@ -1,6 +1,6 @@
[Desktop Entry]
-_Name=Remote Viewer
-_Comment=Access remote desktops
+Name=Remote Viewer
+Comment=Access remote desktops
Exec=remote-viewer %u
Type=Application
Terminal=false
diff --git a/data/virt-viewer-mime.xml.in b/data/virt-viewer-mime.xml
similarity index 100%
rename from data/virt-viewer-mime.xml.in
rename to data/virt-viewer-mime.xml
diff --git a/m4/virt-nls.m4 b/m4/virt-nls.m4
new file mode 100644
index 0000000..6f94bcd
--- /dev/null
+++ b/m4/virt-nls.m4
@@ -0,0 +1,45 @@
+dnl gettext utilities
+dnl
+dnl Copyright (C) 2018 Red Hat, Inc.
+dnl
+dnl This library is free software; you can redistribute it and/or
+dnl modify it under the terms of the GNU Lesser General Public
+dnl License as published by the Free Software Foundation; either
+dnl version 2.1 of the License, or (at your option) any later version.
+dnl
+dnl This library is distributed in the hope that it will be useful,
+dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
+dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+dnl Lesser General Public License for more details.
+dnl
+dnl You should have received a copy of the GNU Lesser General Public
+dnl License along with this library. If not, see
+dnl <http://www.gnu.org/licenses/>.
+dnl
+
+AC_DEFUN([VIRT_VIEWER_ARG_NLS],[
+ m4_divert_text([DEFAULTS], [[enable_nls=yes]])
+ AC_ARG_ENABLE([nls],
+ [AS_HELP_STRING([--enable-nls],
+ [NLS @<:@default=yes@:>@])])
+])
+
+AC_DEFUN([VIRT_VIEWER_CHECK_NLS],[
+ dnl GNU gettext tools (optional).
+ AC_CHECK_PROG([XGETTEXT], [xgettext], [xgettext], [no])
+ AC_CHECK_PROG([MSGFMT], [msgfmt], [msgfmt], [no])
+ AC_CHECK_PROG([MSGMERGE], [msgmerge], [msgmerge], [no])
+
+ dnl Check they are the GNU gettext tools.
+ AC_MSG_CHECKING([msgfmt is GNU tool])
+ if $MSGFMT --version >/dev/null 2>&1 && $MSGFMT --version | grep -q 'GNU gettext'; then
+ msgfmt_is_gnu=yes
+ else
+ msgfmt_is_gnu=no
+ fi
+ AC_MSG_RESULT([$msgfmt_is_gnu])
+ AM_CONDITIONAL([ENABLE_NLS], [test "x$enable_nls" = "xyes"])
+ AM_CONDITIONAL([HAVE_GNU_GETTEXT_TOOLS],
+ [test "x$XGETTEXT" != "xno" && test "x$MSGFMT" != "xno" && \
+ test "x$MSGMERGE" != "xno" && test "x$msgfmt_is_gnu" != "xno"])
+])
diff --git a/mingw-virt-viewer.spec.in b/mingw-virt-viewer.spec.in
index df2828c..ac8b6a2 100644
--- a/mingw-virt-viewer.spec.in
+++ b/mingw-virt-viewer.spec.in
@@ -58,7 +58,7 @@ BuildRequires: mingw32-usbredir
BuildRequires: mingw64-usbredir
BuildRequires: pkgconfig
BuildRequires: /usr/bin/pod2man
-BuildRequires: intltool
+BuildRequires: gettext
BuildRequires: icoutils
BuildRequires: dos2unix
BuildRequires: hicolor-icon-theme
diff --git a/po/Makefile.am b/po/Makefile.am
new file mode 100644
index 0000000..c5f7c36
--- /dev/null
+++ b/po/Makefile.am
@@ -0,0 +1,105 @@
+DOMAIN = $(PACKAGE_NAME)
+COPYRIGHT_HOLDER = The Libvirt authors
+MSGID_BUGS_ADDRESS = https://libvirt.org/bugs.html
+
+MAINTAINERCLEANFILES = $(GMOFILES) $(POTFILE)
+
+LANGS := \
+ af am anp ar as ast bal be bg \
+ bn_IN bn bo br brx bs ca cs cy da \
+ de_CH de el en_GB eo es et eu fa fi \
+ fr gl gu he hi hr hu ia \
+ id ilo is it ja ka kk km kn ko \
+ kw_GB kw at kkcor kw kw at uccor ky lt lv mai mk ml \
+ mn mr ms nb nds ne nl nn nso \
+ or pa pl pt_BR pt ro ru si sk sl \
+ sq sr at latin sr sv ta te tg th tr tw \
+ uk ur vi wba yo zh_CN zh_HK zh_TW zu
+
+
+POTFILE_DEPS := $(shell $(SED) 's,^,$(top_srcdir)/,' $(srcdir)/POTFILES)
+POTFILE := $(srcdir)/$(DOMAIN).pot
+POFILES := $(LANGS:%=$(srcdir)/%.po)
+GMOFILES := $(LANGS:%=$(srcdir)/%.gmo)
+
+EXTRA_DIST = \
+ POTFILES \
+ $(POTFILE) \
+ $(POFILES) \
+ $(GMOFILES)
+
+if HAVE_GNU_GETTEXT_TOOLS
+
+XGETTEXT_ARGS = \
+ --default-domain=$(DOMAIN) \
+ --from-code=utf-8 \
+ --add-comments=TRANSLATORS: \
+ --keyword=_ --keyword=N_ \
+ --copyright-holder='$(COPYRIGHT_HOLDER)' \
+ --package-name="$(PACKAGE_NAME)" \
+ --package-version="$(PACKAGE_VERSION)" \
+ --msgid-bugs-address="$(MSGID_BUGS_ADDRESS)" \
+ --directory=$(top_srcdir) \
+ $(NULL)
+
+SED_PO_FIXUP_ARGS = \
+ -e "s|text/plain; charset=CHARSET|text/plain; charset=UTF-8|g" \
+ -e "s|SOME DESCRIPTIVE TITLE|Libvirt package strings|g" \
+ -e "s|Copyright (C) YEAR|Copyright (C) $$(date +'%Y')|" \
+ $(NULL)
+
+
+# Although they're in EXTRA_DIST, we still need to
+# copy these again, because update-gmo will change
+
+# their content, and dist-hook runs after the
+# things in EXTRA_DIST are copied.
+dist-hook: $(GMOFILES)
+ cp -f $(POTFILE) $(distdir)/
+ cp -f $(POFILES) $(distdir)/
+ cp -f $(GMOFILES) $(distdir)/
+
+update-po: $(POFILES)
+
+update-gmo: $(GMOFILES)
+
+$(POTFILE): POTFILES $(POTFILE_DEPS)
+ $(XGETTEXT) -o $@-t $(XGETTEXT_ARGS) \
+ --files-from=$(abs_srcdir)/POTFILES
+ $(SED) $(SED_PO_FIXUP_ARGS) < $@-t > $@
+ rm -f $@-t
+
+$(srcdir)/%.po: $(POTFILE)
+ $(MSGMERGE) --backup=off --no-fuzzy-matching --update $@ $(POTFILE)
+
+$(srcdir)/%.gmo: $(srcdir)/%.po
+ rm -f $@ $@-t
+ $(MSGFMT) -c -o $@-t $<
+ mv $@-t $@
+
+.PRECIOUS: $(POTFILE) $(POFILES)
+
+endif HAVE_GNU_GETTEXT_TOOLS
+
+if ENABLE_NLS
+
+# Cannot use 'localedir' since this conflicts with autoconf.
+langinstdir = $(datadir)/locale
+
+install-data-hook: $(GMOFILES)
+ mkdir -p $(DESTDIR)$(langinstdir)
+ for lang in $(LANGS); do \
+ d=$(DESTDIR)$(langinstdir)/$$lang/LC_MESSAGES; \
+ mkdir -p $$d; \
+ install -m 0644 $(srcdir)/$$lang.gmo $$d/$(DOMAIN).mo; \
+ done
+
+uninstall-hook:
+ for lang in $(LANGS); do \
+ d=$(DESTDIR)$(langinstdir)/$$lang/LC_MESSAGES; \
+ rm -f $$d/$(DOMAIN).mo; \
+ done
+
+endif ENABLE_NLS
+
+-include $(top_srcdir)/git.mk
diff --git a/po/POTFILES b/po/POTFILES
new file mode 100644
index 0000000..9e5685d
--- /dev/null
+++ b/po/POTFILES
@@ -0,0 +1,26 @@
+data/remote-viewer.appdata.xml.in
+data/remote-viewer.desktop.in
+src/remote-viewer-iso-list-dialog.c
+src/remote-viewer-main.c
+src/remote-viewer.c
+src/resources/ui/remote-viewer-connect.ui
+src/resources/ui/remote-viewer-iso-list.ui
+src/resources/ui/virt-viewer-about.ui
+src/virt-viewer-app.c
+src/virt-viewer-auth.c
+src/resources/ui/virt-viewer-auth.ui
+src/virt-viewer-display-vnc.c
+src/virt-viewer-display-vte.c
+src/virt-viewer-file-transfer-dialog.c
+src/virt-viewer-main.c
+src/virt-viewer-session-spice.c
+src/virt-viewer-session-vnc.c
+src/virt-viewer-vm-connection.c
+src/virt-viewer-window.c
+src/virt-viewer-file.c
+src/virt-viewer.c
+src/resources/ui/virt-viewer.ui
+src/resources/ui/virt-viewer-guest-details.ui
+src/resources/ui/virt-viewer-vm-connection.ui
+src/resources/ui/virt-viewer-preferences.ui
+src/resources/ui/virt-viewer-file-transfer-dialog.ui
diff --git a/po/POTFILES.in b/po/POTFILES.in
deleted file mode 100644
index b296134..0000000
--- a/po/POTFILES.in
+++ /dev/null
@@ -1,27 +0,0 @@
-data/remote-viewer.appdata.xml.in
-data/remote-viewer.desktop.in
-data/virt-viewer-mime.xml.in
-src/remote-viewer-iso-list-dialog.c
-src/remote-viewer-main.c
-src/remote-viewer.c
-[type: gettext/glade] src/resources/ui/remote-viewer-connect.ui
-[type: gettext/glade] src/resources/ui/remote-viewer-iso-list.ui
-[type: gettext/glade] src/resources/ui/virt-viewer-about.ui
-src/virt-viewer-app.c
-src/virt-viewer-auth.c
-[type: gettext/glade] src/resources/ui/virt-viewer-auth.ui
-src/virt-viewer-display-vnc.c
-src/virt-viewer-display-vte.c
-src/virt-viewer-file-transfer-dialog.c
-src/virt-viewer-main.c
-src/virt-viewer-session-spice.c
-src/virt-viewer-session-vnc.c
-src/virt-viewer-vm-connection.c
-src/virt-viewer-window.c
-src/virt-viewer-file.c
-src/virt-viewer.c
-[type: gettext/glade] src/resources/ui/virt-viewer.ui
-[type: gettext/glade] src/resources/ui/virt-viewer-guest-details.ui
-[type: gettext/glade] src/resources/ui/virt-viewer-vm-connection.ui
-[type: gettext/glade] src/resources/ui/virt-viewer-preferences.ui
-[type: gettext/glade] src/resources/ui/virt-viewer-file-transfer-dialog.ui
diff --git a/po/README.md b/po/README.md
new file mode 100644
index 0000000..20ebf83
--- /dev/null
+++ b/po/README.md
@@ -0,0 +1,38 @@
+Virt-Viewer Message Translation
+===========================
+
+Virt-Viewer translatable messages are maintained using the GNU Gettext tools
+and file formats, in combination with the Zanata web service.
+
+Source repository
+=================
+
+The virt-viewer GIT repository stores the master "virt-viewer.pot" file and
+full "po" files for translations. The master "virt-viewer.pot" file can be
+re-generated using
+
+ make virt-viewer.pot
+
+The full po files can have their source locations and msgids updated using
+
+ make update-po
+
+Normally these updates are only done when either refreshing translations from
+Zanata, or when creating a new release.
+
+Zanata web service
+==================
+
+The translation of virt-viewer messages has been outsourced to the Fedora
+translation team using the Zanata web service:
+
+ https://fedora.zanata.org/project/view/virt-viewer
+
+As such, changes to translations will generally NOT be accepted as patches
+directly to virt-viewer GIT. Any changes made to "$LANG.mini.po" files in
+virt-viewer GIT will be overwritten and lost the next time content is imported
+from Zanata.
+
+The master "virt-viewer.pot" file is periodically pushed to Zanata to provide
+the translation team with content changes. New translated text is then
+periodically pulled down from Zanata to update the po files.
diff --git a/po/lt.po b/po/lt.po
index 9a18f31..90cdc7b 100644
--- a/po/lt.po
+++ b/po/lt.po
@@ -16,7 +16,7 @@ msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=3; plural=(n%10==1 && n%100!=11 ? 0 : n%10>=2 && (n"
-"%100<10 or n%100>=20) ? 1 : 2)\n"
+"%100<10 || n%100>=20) ? 1 : 2)\n"
"X-Generator: Zanata 3.8.4\n"
#: ../data/remote-viewer.appdata.xml.in.h:1
diff --git a/virt-viewer.spec.in b/virt-viewer.spec.in
index 6c49c02..210de65 100644
--- a/virt-viewer.spec.in
+++ b/virt-viewer.spec.in
@@ -48,7 +48,7 @@ BuildRequires: pkgconfig(spice-client-gtk-3.0) >= @SPICE_GTK_REQUIRED@
BuildRequires: pkgconfig(spice-protocol) >= @SPICE_PROTOCOL_REQUIRED@
%endif
BuildRequires: /usr/bin/pod2man
-BuildRequires: intltool
+BuildRequires: gettext
%if %{with_govirt}
BuildRequires: pkgconfig(govirt-1.0) >= @GOVIRT_REQUIRED@
%endif
--
2.20.1
More information about the virt-tools-list
mailing list