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(a)redhat.com>
---
.gitignore | 7 ---
autogen.sh | 3 +-
configure.ac | 8 ++-
libvirt-gconfig/Makefile.am | 1 +
libvirt-glib/Makefile.am | 1 +
libvirt-gobject/Makefile.am | 1 +
m4/virt-gettext.m4 | 5 --
m4/virt-nls.m4 | 45 ++++++++++++++++
po/Makefile.am | 101 +++++++++++++++++++++++++++++++++++
po/{POTFILES.in => POTFILES} | 0
po/README.md | 38 +++++++++++++
11 files changed, 191 insertions(+), 19 deletions(-)
delete mode 100644 m4/virt-gettext.m4
create mode 100644 m4/virt-nls.m4
create mode 100644 po/Makefile.am
rename po/{POTFILES.in => POTFILES} (100%)
create mode 100644 po/README.md
diff --git a/.gitignore b/.gitignore
index 116bb12..9301e0f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -83,14 +83,7 @@ libvirt-gconfig/tests/test-capabilities-parse
libvirt-gconfig/tests/test-domain-create
libvirt-gconfig/tests/test-domain-parse
.tx/
-po/Makefile
-po/Makefile.in
-po/Makefile.in.in
-po/POTFILES
-po/libvirt-glib.pot
-po/stamp-it
po/*.gmo
-po/.zanata-cache/
tests/test-events
tests/test-gconfig
tests/*.log
diff --git a/autogen.sh b/autogen.sh
index 4f7135f..3b593ce 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -10,7 +10,7 @@ cd $srcdir
DIE=0
-for prog in intltoolize autoreconf automake autoconf libtoolize
+for prog in autoreconf automake autoconf libtoolize
do
($prog --version) < /dev/null > /dev/null 2>&1 || {
echo
@@ -35,7 +35,6 @@ fi
touch ChangeLog AUTHORS
mkdir -p build-aux
-intltoolize --force
autoreconf -if
cd $THEDIR
diff --git a/configure.ac b/configure.ac
index dc743bb..6b66f5d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -112,10 +112,8 @@ PKG_CHECK_MODULES(GOBJECT2, gobject-2.0 >= $GLIB2_REQUIRED)
PKG_CHECK_MODULES(GIO2, gio-2.0 >= $GLIB2_REQUIRED)
PKG_CHECK_MODULES(LIBXML2, libxml-2.0 >= $LIBXML2_REQUIRED)
-LIBVIRT_GLIB_GETTEXT
-dnl Should be in m4/virt-gettext.m4 but intltoolize is too
-dnl dumb to find it there
-IT_PROG_INTLTOOL([0.35.0])
+LIBVIRT_GLIB_ARG_NLS
+LIBVIRT_GLIB_CHECK_NLS
GTK_DOC_CHECK([1.10],[--flavour no-tmpl])
@@ -218,7 +216,7 @@ AC_OUTPUT(Makefile
docs/libvirt-glib/version.xml
docs/libvirt-gobject/Makefile
docs/libvirt-gconfig/Makefile
- po/Makefile.in
+ po/Makefile
tests/Makefile
libvirt-glib-1.0.pc
libvirt-gconfig-1.0.pc
diff --git a/libvirt-gconfig/Makefile.am b/libvirt-gconfig/Makefile.am
index cfcc0e4..b976e4d 100644
--- a/libvirt-gconfig/Makefile.am
+++ b/libvirt-gconfig/Makefile.am
@@ -201,6 +201,7 @@ libvirt_gconfig_1_0_la_SOURCES = \
nodist_libvirt_gconfig_1_0_la_SOURCES = \
$(GCONFIG_GENERATED_FILES)
libvirt_gconfig_1_0_la_CFLAGS = \
+ -DGETTEXT_PACKAGE="\"libvirt-glib\"" \
-DG_LOG_DOMAIN="\"Libvirt.GConfig\"" \
-DDATADIR="\"$(datadir)\"" \
-DLIBVIRT_GCONFIG_BUILD \
diff --git a/libvirt-glib/Makefile.am b/libvirt-glib/Makefile.am
index 12a390f..fa52352 100644
--- a/libvirt-glib/Makefile.am
+++ b/libvirt-glib/Makefile.am
@@ -16,6 +16,7 @@ libvirt_glib_1_0_la_SOURCES = \
libvirt-glib-main.c
libvirt_glib_1_0_la_CFLAGS = \
-DLIBVIRT_GLIB_BUILD \
+ -DGETTEXT_PACKAGE="\"libvirt-glib\"" \
-DG_LOG_DOMAIN="\"Libvirt.GLib\"" \
-DLOCALEDIR="\"$(datadir)/locale\"" \
$(COVERAGE_CFLAGS) \
diff --git a/libvirt-gobject/Makefile.am b/libvirt-gobject/Makefile.am
index 5e130ee..210c753 100644
--- a/libvirt-gobject/Makefile.am
+++ b/libvirt-gobject/Makefile.am
@@ -66,6 +66,7 @@ libvirt_gobject_1_0_la_SOURCES = \
nodist_libvirt_gobject_1_0_la_SOURCES = \
$(GOBJECT_GENERATED_FILES)
libvirt_gobject_1_0_la_CFLAGS = \
+ -DGETTEXT_PACKAGE="\"libvirt-glib\"" \
-DG_LOG_DOMAIN="\"Libvirt.GObject\"" \
-DDATADIR="\"$(datadir)\"" \
-DLIBVIRT_GOBJECT_BUILD \
diff --git a/m4/virt-gettext.m4 b/m4/virt-gettext.m4
deleted file mode 100644
index 07c0920..0000000
--- a/m4/virt-gettext.m4
+++ /dev/null
@@ -1,5 +0,0 @@
-AC_DEFUN([LIBVIRT_GLIB_GETTEXT],[
- GETTEXT_PACKAGE=libvirt-glib
- AC_SUBST(GETTEXT_PACKAGE)
- AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE],"$GETTEXT_PACKAGE", [GETTEXT package
name])
-])
diff --git a/m4/virt-nls.m4 b/m4/virt-nls.m4
new file mode 100644
index 0000000..9dcba16
--- /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([LIBVIRT_GLIB_ARG_NLS],[
+ m4_divert_text([DEFAULTS], [[enable_nls=yes]])
+ AC_ARG_ENABLE([nls],
+ [AS_HELP_STRING([--enable-nls],
+ [NLS @<:@default=yes@:>@])])
+])
+
+AC_DEFUN([LIBVIRT_GLIB_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/po/Makefile.am b/po/Makefile.am
new file mode 100644
index 0000000..279fc47
--- /dev/null
+++ b/po/Makefile.am
@@ -0,0 +1,101 @@
+DOMAIN = $(PACKAGE_NAME)
+COPYRIGHT_HOLDER = The Libvirt authors
+MSGID_BUGS_ADDRESS =
https://libvirt.org/bugs.html
+
+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 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@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:%=$(srcdir)/%) $(distdir)/
+ cp -f $(POFILES:%=$(srcdir)/%) $(distdir)/
+ cp -f $(GMOFILES:%=$(srcdir)/%) $(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
+
+%.po: $(POTFILE)
+ cd $(srcdir) && \
+ $(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
diff --git a/po/POTFILES.in b/po/POTFILES
similarity index 100%
rename from po/POTFILES.in
rename to po/POTFILES
diff --git a/po/README.md b/po/README.md
new file mode 100644
index 0000000..67821a6
--- /dev/null
+++ b/po/README.md
@@ -0,0 +1,38 @@
+Libvirt-Glib Message Translation
+===========================
+
+Libvirt-Glib translatable messages are maintained using the GNU Gettext tools
+and file formats, in combination with the Zanata web service.
+
+Source repository
+=================
+
+The libvirt-glib GIT repository stores the master "libvirt-glib.pot" file and
+full "po" files for translations. The master "libvirt-glib.pot" file
can be
+re-generated using
+
+ make libvirt-glib.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 libvirt-glib messages has been outsourced to the Fedora
+translation team using the Zanata web service:
+
+
https://fedora.zanata.org/project/view/libvirt-glib
+
+As such, changes to translations will generally NOT be accepted as patches
+directly to libvirt-glib GIT. Any changes made to "$LANG.mini.po" files in
+libvirt-glib GIT will be overwritten and lost the next time content is imported
+from Zanata.
+
+The master "libvirt-glib.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.
--
2.20.1