[libvirt] [PATCH] i18n: simplify mini po generation

Marty E. Plummer posted 1 patch 4 years, 11 months ago
Test syntax-check passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20190518155601.10541-1-hanetzer@startmail.com
Makefile.am              |  1 -
build-aux/minimize-po.pl | 37 -------------------------------------
po/Makefile.am           |  8 +++-----
3 files changed, 3 insertions(+), 43 deletions(-)
delete mode 100755 build-aux/minimize-po.pl
[libvirt] [PATCH] i18n: simplify mini po generation
Posted by Marty E. Plummer 4 years, 11 months ago
If you pass --for-msgfmt to msgmerge it will automatically do most of
what you had the perl script doing.

Signed-off-by: Marty E. Plummer <hanetzer@startmail.com>
---
The only downside I can see is the loss of the comment headers with the
copyright year and such. A global note in the README.md or so may be an
acceptable change.

 Makefile.am              |  1 -
 build-aux/minimize-po.pl | 37 -------------------------------------
 po/Makefile.am           |  8 +++-----
 3 files changed, 3 insertions(+), 43 deletions(-)
 delete mode 100755 build-aux/minimize-po.pl

diff --git a/Makefile.am b/Makefile.am
index dedd8d2ff8..ca7e012512 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -46,7 +46,6 @@ EXTRA_DIST = \
   build-aux/check-spacing.pl \
   build-aux/gitlog-to-changelog \
   build-aux/header-ifdef.pl \
-  build-aux/minimize-po.pl \
   build-aux/mock-noinline.pl \
   build-aux/prohibit-duplicate-header.pl \
   build-aux/useless-if-before-free \
diff --git a/build-aux/minimize-po.pl b/build-aux/minimize-po.pl
deleted file mode 100755
index 497533a836..0000000000
--- a/build-aux/minimize-po.pl
+++ /dev/null
@@ -1,37 +0,0 @@
-#!/usr/bin/perl
-
-my @block;
-my $msgstr = 0;
-my $empty = 0;
-my $unused = 0;
-my $fuzzy = 0;
-while (<>) {
-    if (/^$/) {
-        if (!$empty && !$unused && !$fuzzy) {
-            print @block;
-        }
-        @block = ();
-        $msgstr = 0;
-        $fuzzy = 0;
-        push @block, $_;
-    } else {
-        if (/^msgstr/) {
-            $msgstr = 1;
-            $empty = 1;
-        }
-        if (/^#.*fuzzy/) {
-            $fuzzy = 1;
-        }
-        if (/^#~ msgstr/) {
-            $unused = 1;
-        }
-        if ($msgstr && /".+"/) {
-            $empty = 0;
-        }
-        push @block, $_;
-    }
-}
-
-if (@block && !$empty && !$unused) {
-    print @block;
-}
diff --git a/po/Makefile.am b/po/Makefile.am
index da117edbd5..9ac0bf3357 100644
--- a/po/Makefile.am
+++ b/po/Makefile.am
@@ -55,11 +55,9 @@ update-gmo: $(GMOFILES)
 update-mini-po: $(POTFILE)
 	for lang in $(LANGS); do \
 	  echo "Minimizing $$lang content" && \
-	  $(MSGMERGE) --no-location --no-fuzzy-matching --sort-output \
-	    $$lang.po $(POTFILE) | \
-	  $(SED) $(SED_PO_FIXUP_ARGS) | \
-	  $(PERL) $(top_srcdir)/build-aux/minimize-po.pl > \
-	    $(srcdir)/$$lang.mini.po ; \
+	  $(MSGMERGE) --for-msgfmt --sort-output \
+	    $$lang.po $(POTFILE) \
+	    -o $(srcdir)/$$lang.mini.po ; \
 	done
 
 push-pot: $(POTFILE)
-- 
2.21.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] i18n: simplify mini po generation
Posted by Daniel P. Berrangé 4 years, 11 months ago
On Sat, May 18, 2019 at 10:56:01AM -0500, Marty E. Plummer wrote:
> If you pass --for-msgfmt to msgmerge it will automatically do most of
> what you had the perl script doing.

What msgmerge are you using as that option doesn't exist on Fedora 30
at least ?

  $ msgmerge --for-msgfmt --sort-output uk.po uk.mini.po
  msgmerge: unrecognized option '--for-msgfmt'
  Try 'msgmerge --help' for more information.

  $ rpm -qf /usr/bin/msgmerge 
  gettext-0.19.8.1-18.fc30.x86_64


> 
> Signed-off-by: Marty E. Plummer <hanetzer@startmail.com>
> ---
> The only downside I can see is the loss of the comment headers with the
> copyright year and such. A global note in the README.md or so may be an
> acceptable change.

Removal of copyright strings is a no-go, as that is a violation of
licensing terms unless it is your own copyright notice you are
removing.


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 :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] i18n: simplify mini po generation
Posted by Marty E. Plummer 4 years, 11 months ago
On Mon, May 20, 2019 at 10:14:32AM +0100, Daniel P. Berrangé wrote:
> On Sat, May 18, 2019 at 10:56:01AM -0500, Marty E. Plummer wrote:
> > If you pass --for-msgfmt to msgmerge it will automatically do most of
> > what you had the perl script doing.
> 
> What msgmerge are you using as that option doesn't exist on Fedora 30
> at least ?
>
sys-deve/gettext-0.20.1 from gentoo. Didn't realize an update snuck in
on me while doing this testing.
>   $ msgmerge --for-msgfmt --sort-output uk.po uk.mini.po
>   msgmerge: unrecognized option '--for-msgfmt'
>   Try 'msgmerge --help' for more information.
> 
>   $ rpm -qf /usr/bin/msgmerge 
>   gettext-0.19.8.1-18.fc30.x86_64
> 
> 
> > 
> > Signed-off-by: Marty E. Plummer <hanetzer@startmail.com>
> > ---
> > The only downside I can see is the loss of the comment headers with the
> > copyright year and such. A global note in the README.md or so may be an
> > acceptable change.
> 
> Removal of copyright strings is a no-go, as that is a violation of
> licensing terms unless it is your own copyright notice you are
> removing.
> 
> 
Here's an idea I came up with to avoid this: move the copyright stuff
out of a comment and add it to a translatable string, like so:

diff --git a/po/en_GB.mini.po b/po/en_GB.mini.po
index bbc61fe4c4..a1a14a0b53 100644
--- a/po/en_GB.mini.po
+++ b/po/en_GB.mini.po
@@ -1,17 +1,8 @@
-# Libvirt package strings.
-# Copyright (C) 2019 Red Hat, Inc.
-# This file is distributed under the same license as the PACKAGE package.
-#
-# Translators:
-# Abigail Brady <morwen@evilmagic.org>, Bastien Nocera <hadess@hadess.net>, 2007
-# Daniel <veillard@redhat.com>, 2011
-# Daniel <veillard@redhat.com>, 2011
-# readmanr <robert_readman@hotmail.com>, 2013
 msgid ""
 msgstr ""
 "Project-Id-Version: libvirt 4.10.0\n"
 "Report-Msgid-Bugs-To: https://libvirt.org/bugs.html\n"
-"POT-Creation-Date: 2019-01-14 16:56+0000\n"
+"POT-Creation-Date: 2019-05-19 06:29-0500\n"
 "PO-Revision-Date: 2015-02-24 06:05+0000\n"
 "Last-Translator: Copied by Zanata <copied-by-zanata@zanata.org>\n"
 "Language-Team: English (United Kingdom) (http://www.transifex.com/projects/p/"
@@ -23,6 +14,14 @@ msgstr ""
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 "X-Generator: Zanata 4.6.2\n"
 
+msgid "0Translators:"
+msgstr ""
+"Translators:\n"
+"Abigail Brady <morwen@evilmagic.org>, Bastien Nocera <hadess@hadess.net>, 2007\n"
+"Daniel <veillard@redhat.com>, 2011\n"
+"Daniel <veillard@redhat.com>, 2011\n"
+"readmanr <robert_readman@hotmail.com>, 2013\n"
+
 msgid ""
 "\n"
 "  (specify help <command> for details about the command)\n"

I'm not too sure if there is some form of command like `virtsh --copyright`
one coudl use, but if so, adding that to there would be a great idea, I
think.

Regards,
Marty.
> 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 :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] i18n: simplify mini po generation
Posted by Daniel P. Berrangé 4 years, 11 months ago
On Mon, May 20, 2019 at 02:59:27PM -0500, Marty E. Plummer wrote:
> On Mon, May 20, 2019 at 10:14:32AM +0100, Daniel P. Berrangé wrote:
> > On Sat, May 18, 2019 at 10:56:01AM -0500, Marty E. Plummer wrote:
> > > If you pass --for-msgfmt to msgmerge it will automatically do most of
> > > what you had the perl script doing.
> > 
> > What msgmerge are you using as that option doesn't exist on Fedora 30
> > at least ?
> >
> sys-deve/gettext-0.20.1 from gentoo. Didn't realize an update snuck in
> on me while doing this testing.

Ok, I'm afraid we can't rely on that as we need to build with much
older distros - RHEL-7 for example.

> > > Signed-off-by: Marty E. Plummer <hanetzer@startmail.com>
> > > ---
> > > The only downside I can see is the loss of the comment headers with the
> > > copyright year and such. A global note in the README.md or so may be an
> > > acceptable change.
> > 
> > Removal of copyright strings is a no-go, as that is a violation of
> > licensing terms unless it is your own copyright notice you are
> > removing.
> > 
> > 
> Here's an idea I came up with to avoid this: move the copyright stuff
> out of a comment and add it to a translatable string, like so:

That's changing the format of the file which is not something I
wish to do. Since we can't rely on that new gettext it doesn't
really matter though, since we can't take this approach at all.


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 :|

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list