mcst-linux-kernel/patches-2024.06.26/virt-viewer-8.0/0001-no_intltool_upstream.p...

499 lines
15 KiB
Diff

From 8089cddfcbf0e4446e2d17088ca45e35b2ff28ab Mon Sep 17 00:00:00 2001
From: Daniel P. Berrangé <berrange@redhat.com>
Date: Mar 12 2019 11:49:38 +0000
Subject: po: provide custom make rules for po file management
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 virt-viewer has, so stop using intltool
and don't use gettextize ether.
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
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 02a3830..7b61821 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..5fe4bb6 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -4,8 +4,12 @@ MANUFACTURER = Virt Manager Project
EXTRA_DIST = \
virt-viewer.wxs.in \
+ gettext/its/mime.its \
+ gettext/its/mime.loc \
$(NULL)
+PO_FILES = $(wildcard $(srcdir)/../po/*.po)
+
# this make sure those files are regenerated when they change
# (in maintainer-mode)
all-local: virt-viewer.wxs
@@ -68,17 +72,20 @@ else #!WIN32
desktopdir = $(datadir)/applications
DESKTOPFILES = remote-viewer.desktop.in
desktop_DATA = $(DESKTOPFILES:.desktop.in=.desktop)
-@INTLTOOL_DESKTOP_RULE@
+%.desktop: %.desktop.in $(PO_FILES)
+ $(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
-@INTLTOOL_XML_RULE@
+%-mime.xml: %-mime.xml.in $(PO_FILES)
+ $(AM_V_GEN)GETTEXTDATADIR=$(srcdir)/gettext $(MSGFMT) --xml --template $< -d $(top_srcdir)/po -o $@
appdatadir = $(datadir)/appdata
APPDATAFILES = remote-viewer.appdata.xml.in
appdata_DATA = $(APPDATAFILES:.xml.in=.xml)
-@INTLTOOL_XML_RULE@
+%.appdata.xml: %.appdata.xml.in $(PO_FILES)
+ $(AM_V_GEN)$(MSGFMT) --xml --template $< -d $(top_srcdir)/po -o $@
install-data-hook:
if ENABLE_UPDATE_MIMEDB
diff --git a/data/gettext/its/mime.its b/data/gettext/its/mime.its
new file mode 100644
index 0000000..dec8d13
--- /dev/null
+++ b/data/gettext/its/mime.its
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<its:rules xmlns:its="http://www.w3.org/2005/11/its"
+ version="2.0">
+ <its:translateRule selector="/mime-info" translate="no"/>
+ <its:translateRule selector="//comment" translate="yes"/>
+</its:rules>
diff --git a/data/gettext/its/mime.loc b/data/gettext/its/mime.loc
new file mode 100644
index 0000000..a34fe8d
--- /dev/null
+++ b/data/gettext/its/mime.loc
@@ -0,0 +1,6 @@
+<?xml version="1.0"?>
+<locatingRules>
+ <locatingRule name="mime" pattern="*.xml">
+ <documentRule localName="mime-info" target="mime.its"/>
+ </locatingRule>
+</locatingRules>
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/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 79c8213..2f09350 100644
--- a/mingw-virt-viewer.spec.in
+++ b/mingw-virt-viewer.spec.in
@@ -59,7 +59,7 @@ BuildRequires: mingw32-usbredir
BuildRequires: mingw64-usbredir
BuildRequires: pkgconfig
BuildRequires: /usr/bin/pod2man
-BuildRequires: intltool
+BuildRequires: gettext
BuildRequires: icoutils
BuildRequires: dos2unix
BuildRequires: hwdata
diff --git a/po/Makefile.am b/po/Makefile.am
new file mode 100644
index 0000000..479b398
--- /dev/null
+++ b/po/Makefile.am
@@ -0,0 +1,105 @@
+DOMAIN = $(PACKAGE_NAME)
+COPYRIGHT_HOLDER = The Virt Viewer authors
+MSGID_BUGS_ADDRESS = https://virt-manager.org/bugs/
+
+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@kkcor kw kw@uccor ky 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@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|Virt Viewer 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..f6997bf
--- /dev/null
+++ b/po/POTFILES
@@ -0,0 +1,27 @@
+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
+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/virt-viewer.spec.in b/virt-viewer.spec.in
index 445326f..eea5a74 100644
--- a/virt-viewer.spec.in
+++ b/virt-viewer.spec.in
@@ -47,7 +47,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