Re: [virt-tools-list] [virt-viewer PATCH 01/14] po: provide custom make rules for po file management
On Mon, Mar 11, 2019 at 12:05:25PM +0100, Christophe Fergeau wrote: > Hey, > > On Thu, Mar 07, 2019 at 02:42:45PM +, Daniel P. Berrangé wrote: > > After investigating in more detail it seems you can provide custom rules > > for XML files by setting GETTEXTDATADIR, so I can support mime files with > > this extra diff: > > Ah indeed, nice finding. Seeing what is shipped in > https://git.savannah.gnu.org/cgit/gettext.git/tree/gettext-tools/its > (gsettings, glade, ... rules), this mime rule could probably go there as > well. > > > > > diff --git a/data/Makefile.am b/data/Makefile.am > > index 0e50f3d..d4089be 100644 > > --- a/data/Makefile.am > > +++ b/data/Makefile.am > > @@ -4,6 +4,8 @@ MANUFACTURER = Virt Manager Project > > > > EXTRA_DIST = \ > > virt-viewer.wxs.in \ > > + gettext/its/mime.its\ > > + gettext/its/mime.loc\ > > $(NULL) > > > > # this make sure those files are regenerated when they change > > @@ -71,8 +73,11 @@ desktop_DATA = $(DESKTOPFILES:.desktop.in=.desktop) > > %.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 > > +%-mime.xml: %-mime.xml.in > > + $(AM_V_GEN)GETTEXTDATADIR=$(srcdir)/gettext $(MSGFMT) --xml > > --template $< -d $(top_srcdir)/po -o $@ > > Something I just noticed (but which is related to the initial patch > rather than this one) is that the .xml.in -> .xml rule is no longer > triggered when one of the .po file changes (same for the .desktop file). > I tried adding $(wildcard $(top_srcdir)/po/*.po) as a dependency, and as > far as I can tell, this is giving the behaviour I want. Yes, I can see the original rule had such a dep $ grep XML_RULE /usr/share/aclocal/intltool.m4 INTLTOOL_XML_RULE='%.xml: %.xml.in $(INTLTOOL_MERGE) $(wildcard $(top_srcdir)/po/*.po) I'll add this dep before pushing. Regards, Daniel -- |: https://berrange.com -o-https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o-https://fstop138.berrange.com :| |: https://entangle-photo.org-o-https://www.instagram.com/dberrange :| ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [virt-viewer PATCH 01/14] po: provide custom make rules for po file management
Hey, On Thu, Mar 07, 2019 at 02:42:45PM +, Daniel P. Berrangé wrote: > After investigating in more detail it seems you can provide custom rules > for XML files by setting GETTEXTDATADIR, so I can support mime files with > this extra diff: Ah indeed, nice finding. Seeing what is shipped in https://git.savannah.gnu.org/cgit/gettext.git/tree/gettext-tools/its (gsettings, glade, ... rules), this mime rule could probably go there as well. > > diff --git a/data/Makefile.am b/data/Makefile.am > index 0e50f3d..d4089be 100644 > --- a/data/Makefile.am > +++ b/data/Makefile.am > @@ -4,6 +4,8 @@ MANUFACTURER = Virt Manager Project > > EXTRA_DIST = \ > virt-viewer.wxs.in \ > + gettext/its/mime.its\ > + gettext/its/mime.loc\ > $(NULL) > > # this make sure those files are regenerated when they change > @@ -71,8 +73,11 @@ desktop_DATA = $(DESKTOPFILES:.desktop.in=.desktop) > %.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 > +%-mime.xml: %-mime.xml.in > + $(AM_V_GEN)GETTEXTDATADIR=$(srcdir)/gettext $(MSGFMT) --xml > --template $< -d $(top_srcdir)/po -o $@ Something I just noticed (but which is related to the initial patch rather than this one) is that the .xml.in -> .xml rule is no longer triggered when one of the .po file changes (same for the .desktop file). I tried adding $(wildcard $(top_srcdir)/po/*.po) as a dependency, and as far as I can tell, this is giving the behaviour I want. A similar change is needed in po/Makefile.am in the call to xgettext, and virt-viewer-mime.xml.in needs to be listed in POTFILES, with these changes I can now translate the mime file! Thanks, Christophe signature.asc Description: PGP signature ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [virt-viewer PATCH 01/14] po: provide custom make rules for po file management
On Tue, Mar 05, 2019 at 11:51:01AM +0100, Christophe Fergeau wrote: > On Tue, Mar 05, 2019 at 10:27:07AM +, Daniel P. Berrangé wrote: > > On Tue, Mar 05, 2019 at 11:23:34AM +0100, Christophe Fergeau wrote: > > > On Wed, Feb 20, 2019 at 05:50:52PM +, Daniel P. Berrangé wrote: > > > > 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 > > > > > > s/libvirt-glib/virt-viewer > > > > > > > and don't use gettextize ether. > > > > > > > Signed-off-by: Daniel P. Berrangé > > > > > > > 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) > > > > -@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 > > > > -@INTLTOOL_XML_RULE@ > > > > > > Why drop translations from the mime file? > > > > I don't see any other existing mime files translated, and the gettext > > tools don't recognise the file format AFAICT, so I didn't look like > > this was really needed in the first place. > > On my system, grep -l xml:lang /usr/share/mime/packages/* gives a few > hits, including libreoffice, scribus and the main shared-mime-info file. After investigating in more detail it seems you can provide custom rules for XML files by setting GETTEXTDATADIR, so I can support mime files with this extra diff: diff --git a/data/Makefile.am b/data/Makefile.am index 0e50f3d..d4089be 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -4,6 +4,8 @@ MANUFACTURER = Virt Manager Project EXTRA_DIST = \ virt-viewer.wxs.in \ + gettext/its/mime.its\ + gettext/its/mime.loc\ $(NULL) # this make sure those files are regenerated when they change @@ -71,8 +73,11 @@ desktop_DATA = $(DESKTOPFILES:.desktop.in=.desktop) %.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 +%-mime.xml: %-mime.xml.in + $(AM_V_GEN)GETTEXTDATADIR=$(srcdir)/gettext $(MSGFMT) --xml --template $< -d $(top_srcdir)/po -o $@ appdatadir = $(datadir)/appdata APPDATAFILES = remote-viewer.appdata.xml.in @@ -92,8 +97,8 @@ if ENABLE_UPDATE_MIMEDB $(UPDATE_MIME_DATABASE) "$(DESTDIR)$(datadir)/mime"; endif -CLEANFILES += $(desktop_DATA) $(appdata_DATA) -EXTRA_DIST += $(mime_DATA) $(DESKTOPFILES) $(APPDATAFILES) +CLEANFILES += $(mime_DATA) $(desktop_DATA) $(appdata_DATA) +EXTRA_DIST += $(MIMEFILES) $(DESKTOPFILES) $(APPDATAFILES) endif diff --git a/data/gettext/its/mime.its b/data/gettext/its/mime.its new file mode 100644 index 000..dec8d13 --- /dev/null +++ b/data/gettext/its/mime.its @@ -0,0 +1,6 @@ + +http://www.w3.org/2005/11/its; + version="2.0"> + + + diff --git a/data/gettext/its/mime.loc b/data/gettext/its/mime.loc new file mode 100644 index 000..a34fe8d --- /dev/null +++ b/data/gettext/its/mime.loc @@ -0,0 +1,6 @@ + + + + + + diff --git a/data/virt-viewer-mime.xml b/data/virt-viewer-mime.xml.in similarity index 100% rename from data/virt-viewer-mime.xml rename to data/virt-viewer-mime.xml.in Regards, Daniel -- |: https://berrange.com -o-https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o-https://fstop138.berrange.com :| |: https://entangle-photo.org-o-https://www.instagram.com/dberrange :| ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [virt-viewer PATCH 01/14] po: provide custom make rules for po file management
On Tue, Mar 05, 2019 at 10:27:07AM +, Daniel P. Berrangé wrote: > On Tue, Mar 05, 2019 at 11:23:34AM +0100, Christophe Fergeau wrote: > > On Wed, Feb 20, 2019 at 05:50:52PM +, Daniel P. Berrangé wrote: > > > 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 > > > > s/libvirt-glib/virt-viewer > > > > > and don't use gettextize ether. > > > > > Signed-off-by: Daniel P. Berrangé > > > > > 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) > > > -@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 > > > -@INTLTOOL_XML_RULE@ > > > > Why drop translations from the mime file? > > I don't see any other existing mime files translated, and the gettext > tools don't recognise the file format AFAICT, so I didn't look like > this was really needed in the first place. On my system, grep -l xml:lang /usr/share/mime/packages/* gives a few hits, including libreoffice, scribus and the main shared-mime-info file. Christophe signature.asc Description: PGP signature ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
Re: [virt-tools-list] [virt-viewer PATCH 01/14] po: provide custom make rules for po file management
On Wed, Feb 20, 2019 at 05:50:52PM +, Daniel P. Berrangé wrote: > 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 s/libvirt-glib/virt-viewer > and don't use gettextize ether. > Signed-off-by: Daniel P. Berrangé > 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) > -@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 > -@INTLTOOL_XML_RULE@ Why drop translations from the mime file? > 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 @@ > > - > + I assume this change is needed in order for gettext to recognize this xml file as translatable? > remote-viewer.desktop > CC0-1.0 > GPL-2.0+ > - <_name>Remote Viewer > - <_summary>Remotely access virtual machines > + Remote Viewer > + Remotely access virtual machines > > - <_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. > - > + > > > type="default">https://virt-manager.org/appdata/en_US/virt-viewer/general.png > diff --git a/po/Makefile.am b/po/Makefile.am > new file mode 100644 > index 000..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 This needs to be updated > + > +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 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" \ This string needs to be updated too > + -e "s|Copyright (C) YEAR|Copyright (C) $$(date +'%Y')|" \ > + $(NULL) > + > 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 Probably not needed here? Christophe signature.asc Description: PGP signature ___ virt-tools-list mailing list virt-tools-list@redhat.com https://www.redhat.com/mailman/listinfo/virt-tools-list
[virt-tools-list] [virt-viewer PATCH 01/14] 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 libvirt-glib has, so stop using intltool and don't use gettextize ether. Signed-off-by: Daniel P. Berrangé --- 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) -@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 -@INTLTOOL_XML_RULE@ appdatadir = $(datadir)/appdata APPDATAFILES = remote-viewer.appdata.xml.in appdata_DATA = $(APPDATAFILES:.xml.in=.xml) -@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 +=