[virt-tools-list] [virt-viewer PATCH 01/14] po: provide custom make rules for po file management

Daniel P. Berrangé berrange at redhat.com
Thu Mar 7 14:42:45 UTC 2019


On Tue, Mar 05, 2019 at 11:51:01AM +0100, Christophe Fergeau wrote:
> On Tue, Mar 05, 2019 at 10:27:07AM +0000, 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 +0000, 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é <berrange at redhat.com>
> > > 
> > > > 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@
> > > 
> > > 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 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/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 :|




More information about the virt-tools-list mailing list