Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
On Thu, 03 Sep 2015 10:19:45 +0900 Daiki Ueno wrote: > Francesco Poliwrites: [...] > > Please support these cases as well, at least by adding a > > --same-copyright option (without arguments) that produces > > a .pot file with > > > > # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER > > > > replaced by > > > > # This file is copyrighted by the PACKAGE package's copyright holders > > # and by the translators listed below. > > > > Of course, PACKAGE should be replaced by the argument of the > > --package-name option, where available. > > If I were going to address all such cases, I would rather add a single > general-purpose --header-file=FILE option. That would be equivalent to > my proposal using sed, and I don't think it worth doing since the sed > snippet is fairly simple. I see that my bug report (on the Debian BTS) has been closed, since the new version 0.19.6 incorporates the changes that you (Daiki) implemented. As I said, I am not especially happy with the result: xgettext has some options to insert copyright notices into the generated .pot file, but it only does half the job and needs "help" from external tools, whenever there are multiple copyright holders. Anyway, I give up: it seems that I failed to persuade you (Daiki) to better support general use cases... :-( Bye. -- http://www.inventati.org/frx/ There's not a second to spare! To the laboratory! . Francesco Poli . GnuPG key fpr == CA01 1147 9CD2 EFDF FB82 3925 3E1C 27E1 1F69 BFFE pgpznWhWGlMr3.pgp Description: PGP signature
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
Francesco Poliwrites: >> I don't think it is boring nor error prone -- it just means to >> concatenate two files. > > Well, not really just a file concatenation... More a job for sed or > awk, as I said. But this would be the case, if you automated the task. I actually pushed this to the git master: http://git.savannah.gnu.org/cgit/gettext.git/commit/?id=e4ec2e69 It is only 5 lines and even smaller than a similar example quoted in the Autoconf manual: http://www.gnu.org/savannah-checkouts/gnu/autoconf/manual/autoconf-2.69/html_node/Installation-Directory-Variables.html#Installation-Directory-Variables > Please support these cases as well, at least by adding a > --same-copyright option (without arguments) that produces > a .pot file with > > # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER > > replaced by > > # This file is copyrighted by the PACKAGE package's copyright holders > # and by the translators listed below. > > Of course, PACKAGE should be replaced by the argument of the > --package-name option, where available. If I were going to address all such cases, I would rather add a single general-purpose --header-file=FILE option. That would be equivalent to my proposal using sed, and I don't think it worth doing since the sed snippet is fairly simple. Regards, -- Daiki Ueno
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
On Mon, 31 Aug 2015 08:21:29 +0900 Daiki Ueno wrote: > Francesco Poliwrites: > > > • I post-process the .pot template generated by xgettext and insert > > the correct copyright notices: this can be done by hand (boring and > > error prone!) or automatically, for instance, with some sed or awk > > trick > > I don't think it is boring nor error prone -- it just means to > concatenate two files. Well, not really just a file concatenation... More a job for sed or awk, as I said. But this would be the case, if you automated the task. I am convinced that doing the substitution *manually* is indeed boring and error prone. > As long as you use autotools, it would be > automatically done by po/Makefile.in.in installed by autopoint. You know, users of xgettext do not necessarily also use autotools... > > So, my question was, why it is not sufficient for your use-case? Is > there any practical reason you have to call xgettext individually, > e.g. your build system doesn't support post-processing for some reason? I am not thinking about a build system with no post-processing support. But what strikes me as weird is that xgettext has some support for inserting appropriate copyright notices, but then leaves the job half-done for all but very simple cases. > > > At this point I am really puzzled. The --copyright-holder option is > > currently inadequate to make sure the .pot template file has the > > correct copyright notices in place. > > The current behavior of --copyright-holder is useful for some use-cases, > e.g., FSF-copyrighted packages (like coreutils, gettext), where > translations are also attributed to the same copyright holder. In that > case, it is natural to leave the responsibility to rewrite YEAR to the > translators. But, as I said, there are many less simple cases out there. Please support these cases as well, at least by adding a --same-copyright option (without arguments) that produces a .pot file with # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER replaced by # This file is copyrighted by the PACKAGE package's copyright holders # and by the translators listed below. Of course, PACKAGE should be replaced by the argument of the --package-name option, where available. Could at least this be done? Thanks for your time and patience. -- http://www.inventati.org/frx/ There's not a second to spare! To the laboratory! . Francesco Poli . GnuPG key fpr == CA01 1147 9CD2 EFDF FB82 3925 3E1C 27E1 1F69 BFFE pgpTEXGP14WcX.pgp Description: PGP signature
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
On Thu, 27 Aug 2015 12:16:10 +0900 Daiki Ueno wrote: Francesco Poli invernom...@paranoici.org writes: I would definitely prefer to see xgettext changed, rather than having to do sed or awk tricks to post-process its output. So, to me, (4) is the least preferred option. Sorry, I am not convinced. Again, I am reluctant to add a new option to xgettext for a niche feature, without good reason. Do you have any practical reason for that? I thought the practical reason was clear: I want to automatically generate a .pot template file from the program source, ready to be sent to prospective translators. xgettext seems to be a suitable tool to achieve this goal. But the .pot template has to include the correct copyright notices, assuming it indeed has to include any copyright notice. Just having a .pot template file which says # Copyright (C) YEAR Python Software Foundation when there are actually more copyright holders, is misleading and confusing (and is vague with respect to the copyright years). So, I am left with two options: • I post-process the .pot template generated by xgettext and insert the correct copyright notices: this can be done by hand (boring and error prone!) or automatically, for instance, with some sed or awk trick (but then, why does xgettext have the --copyright-holder option in the first place?!?) • I tell prospective translators to edit the fake copyright notice and replace it with the correct copyright notices (boring for translators and even more error prone!) At this point I am really puzzled. The --copyright-holder option is currently inadequate to make sure the .pot template file has the correct copyright notices in place. Hence, xgettext should have appropriate options to insert the correct copyright notices. Or, alternatively, it should drop the --copyright-holder option entirely and produce a .pot file with # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER replaced by # This file is copyrighted by the PACKAGE package's copyright holders # and by the translators listed below. Of course, PACKAGE should be replaced by the argument of the --package-name option, where available. This way, we could do the following: $ xgettext --package-name=myapplication --package-version=0.1 \ --language=python myapplication.py -o myapplication3.pot $ cat myapplication3.pot # SOME DESCRIPTIVE TITLE. # This file is copyrighted by the myapplication package's copyright holders # and by the translators listed below. # This file is distributed under the same license as the myapplication package. # FIRST AUTHOR EMAIL@ADDRESS, YEAR. # #, fuzzy msgid msgstr Project-Id-Version: myapplication 0.1\n Report-Msgid-Bugs-To: \n POT-Creation-Date: 2012-07-23 22:49+0200\n PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n Last-Translator: FULL NAME EMAIL@ADDRESS\n Language-Team: LANGUAGE l...@li.org\n Language: \n MIME-Version: 1.0\n Content-Type: text/plain; charset=CHARSET\n Content-Transfer-Encoding: 8bit\n #: myapplication.py:6 msgid This is a translatable string. msgstr My reasons for preferring (4) to (3) are: [...] - that fits better in the Unix philosophy, which suggests to accomplish larger tasks by combining small tools As far as I understand the Unix design philosophy, there should be small tools that do one thing (or, at most, a few things) and do it well. xgettext should generate a .pot template file and generate a good one. In my own humble opinion, xgettext is currently failing at generating a good .pot template file, as far as copyright notices are concerned. I hope all this makes sense to you. Please let me know, thanks for your time and patience! :-) -- http://www.inventati.org/frx/ There's not a second to spare! To the laboratory! . Francesco Poli . GnuPG key fpr == CA01 1147 9CD2 EFDF FB82 3925 3E1C 27E1 1F69 BFFE pgps2sfuByZqa.pgp Description: PGP signature
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
Francesco Poli invernom...@paranoici.org writes: • I post-process the .pot template generated by xgettext and insert the correct copyright notices: this can be done by hand (boring and error prone!) or automatically, for instance, with some sed or awk trick I don't think it is boring nor error prone -- it just means to concatenate two files. As long as you use autotools, it would be automatically done by po/Makefile.in.in installed by autopoint. So, my question was, why it is not sufficient for your use-case? Is there any practical reason you have to call xgettext individually, e.g. your build system doesn't support post-processing for some reason? At this point I am really puzzled. The --copyright-holder option is currently inadequate to make sure the .pot template file has the correct copyright notices in place. The current behavior of --copyright-holder is useful for some use-cases, e.g., FSF-copyrighted packages (like coreutils, gettext), where translations are also attributed to the same copyright holder. In that case, it is natural to leave the responsibility to rewrite YEAR to the translators. Regards, -- Daiki Ueno
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
On Tue, 25 Aug 2015 11:58:31 +0900 Daiki Ueno wrote: Francesco Poli invernom...@paranoici.org writes: I'd definitely vote for 3, but, wait!, even better, I would add a new option named --copyright-notices (or maybe there's a better name, I don't know...), where all the copyright notices may be specified with their own line breaks, as in: I'm afraid it would break configurability through po/Makevars, since a make variable including a multi-line argument cannot be used in a portable Makefile. That's unfortunate. By the way, if we chose (4), the patch would be like the attached, which reads the file po/HEADER (if exists) and insert the content into POT file. The file would look like: # Copyright (C) 2001-2012 Python Software Foundation. # Copyright (C) 2000 BeOpen.com. # Copyright (C) 1995-2000 Corporation for National Research Initiatives. # Copyright (C) 1991-1995 Stichting Mathematisch Centrum. If this is sufficient, I would revert the multiple --copyright-holder change, as I am reluctant to add new option to xgettext, which already has too many options. I would definitely prefer to see xgettext changed, rather than having to do sed or awk tricks to post-process its output. So, to me, (4) is the least preferred option. Since multi-line arguments cause problems, maybe an option named --copyright-notice could be implemented in xgettext, to be used multiple times as in: $ xgettext --copyright-notice=Copyright (C) 2001-2012 Python Software Foundation. \ --copyright-notice=Copyright (C) 2000 BeOpen.com. \ --copyright-notice=Copyright (C) 1995-2000 Corporation for National Research Initiatives. \ --copyright-notice=Copyright (C) 1991-1995 Stichting Mathematisch Centrum. \ --package-name=myapplication --package-version=0.1 \ --language=python myapplication.py -o myapplication2.pot Again, this would cause myapplication2.pot to include: # Copyright (C) 2001-2012 Python Software Foundation. # Copyright (C) 2000 BeOpen.com. # Copyright (C) 1995-2000 Corporation for National Research Initiatives. # Copyright (C) 1991-1995 Stichting Mathematisch Centrum. in stead of: # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER I hope you think this is a good suggestion. Please let me know, thanks for your time! -- http://www.inventati.org/frx/ There's not a second to spare! To the laboratory! . Francesco Poli . GnuPG key fpr == CA01 1147 9CD2 EFDF FB82 3925 3E1C 27E1 1F69 BFFE pgpSr4uEzrHcX.pgp Description: PGP signature
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
Francesco Poli invernom...@paranoici.org writes: I would definitely prefer to see xgettext changed, rather than having to do sed or awk tricks to post-process its output. So, to me, (4) is the least preferred option. Sorry, I am not convinced. Again, I am reluctant to add a new option to xgettext for a niche feature, without good reason. Do you have any practical reason for that? My reasons for preferring (4) to (3) are: - we could give more control to users, for example, inserting arbitrary text other than copyright notice - we are already using sed in po/Makefile.in.in, as in en@quot rules - having multiple --copyright-foo options doesn't seem to play nicely with the feature supplying COPYRIGHT_HOLDER from autoconf (bug 764483) - that fits better in the Unix philosophy, which suggests to accomplish larger tasks by combining small tools Regards, -- Daiki Ueno
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
Francesco Poli invernom...@paranoici.org writes: Besides that, the patch seems to only address point (B) of my original bug report (multiple copyright holders), but not point (A) or point (C) (YEAR and PACKAGE placeholders). Or am I misreading the patch? As (C) is trivial, I've pushed a fix: http://git.savannah.gnu.org/cgit/gettext.git/commit/?id=3a08add5 However, I have not yet decided how to fix (A). A few options I have in mind are: 1. add --copyright-year option 2. extend --copyright-holder option so it can have a full copyright notice, if the argument is in the form Copyright (C) 3. add a new option, say --add-copyright, which takes an argument in the form YEAR COPYRIGHT_HOLDER. 4. don't change xgettext, but modify po/Makefile.in.in to insert copyright comments, using sed I think (1) is not very useful, particularly when multiple copyright holders are supplied, and (2) is a bit heuristic. So, I prefer (3) or (4), as both of them could allow users to specify it through po/Makevars, though (3) is a bit too specific. Suggestions would be appreciated. Regards, -- Daiki Ueno
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
On Mon, 24 Aug 2015 18:05:17 +0900 Daiki Ueno wrote: Francesco Poli invernom...@paranoici.org writes: Besides that, the patch seems to only address point (B) of my original bug report (multiple copyright holders), but not point (A) or point (C) (YEAR and PACKAGE placeholders). Or am I misreading the patch? As (C) is trivial, I've pushed a fix: http://git.savannah.gnu.org/cgit/gettext.git/commit/?id=3a08add5 Many thanks for doing so! :-) However, I have not yet decided how to fix (A). A few options I have in mind are: [...] 3. add a new option, say --add-copyright, which takes an argument in the form YEAR COPYRIGHT_HOLDER. [...] Suggestions would be appreciated. I'd definitely vote for 3, but, wait!, even better, I would add a new option named --copyright-notices (or maybe there's a better name, I don't know...), where all the copyright notices may be specified with their own line breaks, as in: $ xgettext --copyright-notices=Copyright (C) 2001-2012 Python Software Foundation. Copyright (C) 2000 BeOpen.com. Copyright (C) 1995-2000 Corporation for National Research Initiatives. Copyright (C) 1991-1995 Stichting Mathematisch Centrum. \ --package-name=myapplication --package-version=0.1 \ --language=python myapplication.py -o myapplication2.pot This would cause myapplication2.pot to include: # Copyright (C) 2001-2012 Python Software Foundation. # Copyright (C) 2000 BeOpen.com. # Copyright (C) 1995-2000 Corporation for National Research Initiatives. # Copyright (C) 1991-1995 Stichting Mathematisch Centrum. in stead of: # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER In other words, the --copyright-notice option would allow the user to specify the copyright notices literally; xgettext would just prepend each copyright notice line with the # comment symbol. Does it sound like a good suggestion? -- http://www.inventati.org/frx/ There's not a second to spare! To the laboratory! . Francesco Poli . GnuPG key fpr == CA01 1147 9CD2 EFDF FB82 3925 3E1C 27E1 1F69 BFFE pgp_hz_FFxA9x.pgp Description: PGP signature
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
Francesco Poli invernom...@paranoici.org writes: I'd definitely vote for 3, but, wait!, even better, I would add a new option named --copyright-notices (or maybe there's a better name, I don't know...), where all the copyright notices may be specified with their own line breaks, as in: I'm afraid it would break configurability through po/Makevars, since a make variable including a multi-line argument cannot be used in a portable Makefile. By the way, if we chose (4), the patch would be like the attached, which reads the file po/HEADER (if exists) and insert the content into POT file. The file would look like: # Copyright (C) 2001-2012 Python Software Foundation. # Copyright (C) 2000 BeOpen.com. # Copyright (C) 1995-2000 Corporation for National Research Initiatives. # Copyright (C) 1991-1995 Stichting Mathematisch Centrum. If this is sufficient, I would revert the multiple --copyright-holder change, as I am reluctant to add new option to xgettext, which already has too many options. Regards, -- Daiki Ueno From c8f8099dca7976fa26d7ac671446144f1fe044c9 Mon Sep 17 00:00:00 2001 From: Daiki Ueno u...@gnu.org Date: Tue, 25 Aug 2015 11:47:20 +0900 Subject: [PATCH] po: Insert HEADER file into POT file * gettext-tools/po/Makefile.in.in ($(DOMAIN).pot-update): Add insert-header.sed to prerequisites. Insert the contents of the file HEADER. (mostlyclean): Remove insert-header.sed. --- gettext-runtime/po/ChangeLog | 6 ++ gettext-runtime/po/Makefile.in.in | 8 +++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/gettext-runtime/po/ChangeLog b/gettext-runtime/po/ChangeLog index e5d8f0d..73ccaa2 100644 --- a/gettext-runtime/po/ChangeLog +++ b/gettext-runtime/po/ChangeLog @@ -1,3 +1,9 @@ +2015-08-25 Daiki Ueno u...@gnu.org + + * Makefile.in.in ($(DOMAIN).pot-update): Add insert-header.sed to + prerequisites. Insert the contents of the file HEADER. + (mostlyclean): Remove insert-header.sed. + 2015-07-10 Daiki Ueno u...@gnu.org * gettext 0.19.5 released. diff --git a/gettext-runtime/po/Makefile.in.in b/gettext-runtime/po/Makefile.in.in index c36f1ad..f4267ab 100644 --- a/gettext-runtime/po/Makefile.in.in +++ b/gettext-runtime/po/Makefile.in.in @@ -150,7 +150,7 @@ stamp-po: $(srcdir)/$(DOMAIN).pot # The determination of whether the package xyz is a GNU one is based on the # heuristic whether some file in the top level directory mentions GNU xyz. # If GNU 'find' is available, we avoid grepping through monster files. -$(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed +$(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed insert-header.sed package_gnu=$(PACKAGE_GNU); \ test -n $$package_gnu || { \ if { if (LC_ALL=C find --version) 2/dev/null | grep GNU /dev/null; then \ @@ -195,6 +195,11 @@ $(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed ;; \ esac test ! -f $(DOMAIN).po || { \ + if test -f $(srcdir)/HEADER; then \ + sed -f insert-header.sed $(DOMAIN).po $(DOMAIN).1po \ + rm -f $(DOMAIN).po \ + mv $(DOMAIN).1po $(DOMAIN).po; \ + fi; \ if test -f $(srcdir)/$(DOMAIN).pot; then \ sed -f remove-potcdate.sed $(srcdir)/$(DOMAIN).pot $(DOMAIN).1po \ sed -f remove-potcdate.sed $(DOMAIN).po $(DOMAIN).2po \ @@ -365,6 +370,7 @@ info dvi ps pdf html tags TAGS ctags CTAGS ID: mostlyclean: rm -f remove-potcdate.sed + rm -f insert-header.sed rm -f stamp-poT rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po rm -fr *.o -- 2.4.3
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
On Fri, Aug 21, 2015 at 05:49:00PM +0900, Daiki Ueno wrote: What else was remaining to close this bug? In Debian we usually close a bug when there is a new package available in unstable fixing the bug. This is what I will do for the Debian package but of course you might have different rules for the gettext bugzilla.
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
On Fri, 21 Aug 2015 13:06:11 +0200 Santiago Vila wrote: On Fri, Aug 21, 2015 at 05:49:00PM +0900, Daiki Ueno wrote: What else was remaining to close this bug? In Debian we usually close a bug when there is a new package available in unstable fixing the bug. This is what I will do for the Debian package but of course you might have different rules for the gettext bugzilla. Correct. Besides that, the patch seems to only address point (B) of my original bug report (multiple copyright holders), but not point (A) or point (C) (YEAR and PACKAGE placeholders). Or am I misreading the patch? -- http://www.inventati.org/frx/ There's not a second to spare! To the laboratory! . Francesco Poli . GnuPG key fpr == CA01 1147 9CD2 EFDF FB82 3925 3E1C 27E1 1F69 BFFE pgpBSgb69xWVI.pgp Description: PGP signature
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
Daiki Ueno u...@gnu.org writes: By the way, after looking into the history and the documentation more closely, I realized that my argument on copyright notice was pointless. I'm sorry. I'm now in favor of adding support for multiple copyright holders, like the attached patch, which makes xgettext allow multiple --copyright-holder options. Sorry for the delay. I've landed the patch in upstream: http://git.savannah.gnu.org/cgit/gettext.git/commit/?id=15363cca What else was remaining to close this bug? Regards, -- Daiki Ueno
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
On Mon, 20 Jul 2015 08:10:25 +0900 Daiki Ueno wrote: Francesco Poli invernom...@paranoici.org writes: [...] What I really fail to understand is: if some placeholders are replaced by xgettext --copyright-holder=Python Software Foundation \ --package-name=myapplication --package-version=0.1 \ --language=python myapplication.py -o myapplication2.pot why other placeholders are not touched at all?!? First of all, I would repeat that xgettext prepares a template for translators, not a real content. If you want to put the real content there, you can easily adjust it by using an Automake hook. With the above example, the replaced placeholders (i.e., COPYRIGHT HOLDER, PACKAGE, VERSION) are common for all translations derived from the package source code. On the other hand, xgettext intentionally doesn't provide a way to touch some placeholders (YEAR, FULL NAME, LANGUAGE, etc), because it shall be replaced by translators. If you run: msginit -i myapplication2.pot -o ja.po then you will get ja.po with those placeholders properly replaced for translation. I think this is reasonable. If you are still not satisfied with the answer, I'm afraid I doubt I could convince you of that. Then I am afraid we will have to agree to disagree. I am frankly having a hard time in seeing why the placeholder PACKAGE should be replaced in one occurrence, but not in the other. And in figuring out why the placeholder THE PACKAGE'S COPYRIGHT HOLDER should be replaced, while the YEAR placeholder should be left untouched in the *same* copyright notice. Am I the only one who thinks that this is highly asymmetrical and awkward? I am honestly puzzled... -- http://www.inventati.org/frx/ There's not a second to spare! To the laboratory! . Francesco Poli . GnuPG key fpr == CA01 1147 9CD2 EFDF FB82 3925 3E1C 27E1 1F69 BFFE pgpfwWgA88LdZ.pgp Description: PGP signature
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
Francesco Poli invernom...@paranoici.org writes: I am frankly having a hard time in seeing why the placeholder PACKAGE should be replaced in one occurrence, but not in the other. And in figuring out why the placeholder THE PACKAGE'S COPYRIGHT HOLDER should be replaced, while the YEAR placeholder should be left untouched in the *same* copyright notice. I think it would be nice to fix them so those occurrences be replaced as well. By the way, after looking into the history and the documentation more closely, I realized that my argument on copyright notice was pointless. I'm sorry. I'm now in favor of adding support for multiple copyright holders, like the attached patch, which makes xgettext allow multiple --copyright-holder options. It is not straightforward to support multiple copyright holders in po/Makevars, but it might be sufficient to supply it as part of XGETTEXT_OPTIONS in combination with COPYRIGHT_HOLDER. Regards, -- Daiki Ueno From 7aba166af10a4b64aa07d7f5afc91bdd239beef2 Mon Sep 17 00:00:00 2001 From: Daiki Ueno u...@gnu.org Date: Tue, 21 Jul 2015 13:51:31 +0900 Subject: [PATCH] xgettext: Allow multiple copyright holders * gettext-tools/src/xgettext.c (default_copyright_holder): New constant, renamed from copyright_holder. (copyright_holder): Define as a variable. (main): Allow multiple --copyright-holder options. (construct_header): Support multiple --copyright-holder options. --- gettext-tools/src/ChangeLog | 8 + gettext-tools/src/xgettext.c | 70 2 files changed, 72 insertions(+), 6 deletions(-) diff --git a/gettext-tools/src/ChangeLog b/gettext-tools/src/ChangeLog index 6685505..74dd518 100644 --- a/gettext-tools/src/ChangeLog +++ b/gettext-tools/src/ChangeLog @@ -1,3 +1,11 @@ +2015-07-21 Daiki Ueno u...@gnu.org + + * xgettext.c (default_copyright_holder): New constant, renamed + from copyright_holder. + (copyright_holder): Define as a variable. + (main): Allow multiple --copyright-holder options. + (construct_header): Support multiple --copyright-holder options. + 2015-07-10 Daiki Ueno u...@gnu.org * gettext 0.19.5 released. diff --git a/gettext-tools/src/xgettext.c b/gettext-tools/src/xgettext.c index 9f5d300..8e303c7 100644 --- a/gettext-tools/src/xgettext.c +++ b/gettext-tools/src/xgettext.c @@ -124,7 +124,8 @@ message_list_ty *exclude; static int force_po; /* Copyright holder of the output file and the translations. */ -static const char *copyright_holder = THE PACKAGE'S COPYRIGHT HOLDER; +static const char *default_copyright_holder = THE PACKAGE'S COPYRIGHT HOLDER; +static char *copyright_holder = NULL; /* Package name. */ static const char *package_name = NULL; @@ -540,11 +541,19 @@ main (int argc, char *argv[]) break; case CHAR_MAX + 1:/* --copyright-holder */ -copyright_holder = optarg; +if (copyright_holder == NULL) + copyright_holder = xstrdup (optarg); +else + { +size_t total_len = strlen (copyright_holder) + 2 + strlen (optarg); +copyright_holder = xrealloc (copyright_holder, total_len); +strcat (copyright_holder, \n); +strcat (copyright_holder, optarg); + } break; case CHAR_MAX + 2:/* --foreign-user */ -copyright_holder = ; +copyright_holder = xstrdup (); break; case CHAR_MAX + 3:/* --from-code */ @@ -3559,13 +3568,61 @@ Content-Transfer-Encoding: 8bit\n, mp = message_alloc (NULL, , NULL, msgstr, strlen (msgstr) + 1, pos); + if (copyright_holder == NULL) +copyright_holder = xstrdup (default_copyright_holder); + if (copyright_holder[0] != '\0') -comment = xasprintf (\ +{ + size_t copyright_comment_len; + char *copyright_comment; + const char *p; + char *q; + size_t count = 1; + + p = copyright_holder; + while (*p != '\0') +{ + p = strchr (p, '\n'); + if (p == NULL) +break; + count++; + p++; +} + + copyright_comment_len = +strlen (copyright_holder) + strlen (Copyright (C) YEAR \n) * count; + copyright_comment = XNMALLOC (copyright_comment_len, char); + + p = copyright_holder; + q = copyright_comment; + while (*p != '\0') +{ + char *newline = strchr (p, '\n'); + + q = stpcpy (q, Copyright (C) YEAR ); + if (newline != NULL) +{ + *newline = '\0'; + q = stpcpy (q, p); + q = stpcpy (q, \n); + p = newline + 1; +} + else +{ + q = stpcpy (q, p); + q = stpcpy (q, \n); + break; +} +} + + comment = xasprintf (\ SOME DESCRIPTIVE TITLE.\n\ -Copyright (C) YEAR %s\n\ +%s\ This file is distributed under the same license as the PACKAGE package.\n\ FIRST AUTHOR EMAIL@ADDRESS,
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
Francesco Poli invernom...@paranoici.org writes: dist-hook: echo # Copyright (C) ... $(distdir)/po/hello.pot This would place the copyright notice at the end of the .pot file, wouldn't it? This is not necessarily what one would want to do. I just gave you an example how it could be done. It is easy to rewrite it to put the copyright notice at the top, by using a temporary file. What I really fail to understand is: if some placeholders are replaced by xgettext --copyright-holder=Python Software Foundation \ --package-name=myapplication --package-version=0.1 \ --language=python myapplication.py -o myapplication2.pot why other placeholders are not touched at all?!? First of all, I would repeat that xgettext prepares a template for translators, not a real content. If you want to put the real content there, you can easily adjust it by using an Automake hook. With the above example, the replaced placeholders (i.e., COPYRIGHT HOLDER, PACKAGE, VERSION) are common for all translations derived from the package source code. On the other hand, xgettext intentionally doesn't provide a way to touch some placeholders (YEAR, FULL NAME, LANGUAGE, etc), because it shall be replaced by translators. If you run: msginit -i myapplication2.pot -o ja.po then you will get ja.po with those placeholders properly replaced for translation. I think this is reasonable. If you are still not satisfied with the answer, I'm afraid I doubt I could convince you of that. Regards, -- Daiki Ueno -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
On Wed, 15 Jul 2015 07:03:51 +0900 Daiki Ueno wrote: Francesco Poli invernom...@paranoici.org writes: On Tue, 14 Jul 2015 10:48:20 +0900 Daiki Ueno wrote: I noticed that xgettext does not properly replace all the relevant placeholders in the output .pot file, when told to do so through command-line options. I doubt if it is meaningful to have a real copyright notice in an auto-generated template file. Well, the auto-generated .pot file is auto-generated by extracting many strings from a number of copyrighted source code files. I think that, in most cases, this implies that the .pot file is copyrighted and has the same copyright owners and copyright years as the source files. As a consequence, I think it makes definitely sense for it to carry real copyright notices (the same that cover the source files, in most cases). Yes. However, xgettext is not intended for generating a real header entry, but for generating a template of a header entry. If one really wants to carry a real copyright notice in a POT file, she could easily do that from without xgettext, e.g., in the toplevel Makefile.am: dist-hook: echo # Copyright (C) ... $(distdir)/po/hello.pot I am not sure I understand this correctly. This would place the copyright notice at the end of the .pot file, wouldn't it? This is not necessarily what one would want to do. Maybe one could use sed to replace the remaining placeholders, but anyway it feels like a kludge... What I really fail to understand is: if some placeholders are replaced by xgettext --copyright-holder=Python Software Foundation \ --package-name=myapplication --package-version=0.1 \ --language=python myapplication.py -o myapplication2.pot why other placeholders are not touched at all?!? -- http://www.inventati.org/frx/ There's not a second to spare! To the laboratory! . Francesco Poli . GnuPG key fpr == CA01 1147 9CD2 EFDF FB82 3925 3E1C 27E1 1F69 BFFE pgpN6l4sLcEvQ.pgp Description: PGP signature
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
Francesco Poli invernom...@paranoici.org writes: On Tue, 14 Jul 2015 10:48:20 +0900 Daiki Ueno wrote: I noticed that xgettext does not properly replace all the relevant placeholders in the output .pot file, when told to do so through command-line options. I doubt if it is meaningful to have a real copyright notice in an auto-generated template file. Well, the auto-generated .pot file is auto-generated by extracting many strings from a number of copyrighted source code files. I think that, in most cases, this implies that the .pot file is copyrighted and has the same copyright owners and copyright years as the source files. As a consequence, I think it makes definitely sense for it to carry real copyright notices (the same that cover the source files, in most cases). Yes. However, xgettext is not intended for generating a real header entry, but for generating a template of a header entry. If one really wants to carry a real copyright notice in a POT file, she could easily do that from without xgettext, e.g., in the toplevel Makefile.am: dist-hook: echo # Copyright (C) ... $(distdir)/po/hello.pot Regards, -- Daiki Ueno -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Bug#682580: [bug-gettext] Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER) (fwd)
On Tue, 14 Jul 2015 10:48:20 +0900 Daiki Ueno wrote: I noticed that xgettext does not properly replace all the relevant placeholders in the output .pot file, when told to do so through command-line options. I doubt if it is meaningful to have a real copyright notice in an auto-generated template file. Well, the auto-generated .pot file is auto-generated by extracting many strings from a number of copyrighted source code files. I think that, in most cases, this implies that the .pot file is copyrighted and has the same copyright owners and copyright years as the source files. As a consequence, I think it makes definitely sense for it to carry real copyright notices (the same that cover the source files, in most cases). The gettext manual suggests that those placeholders shall be replaced by translators: http://www.gnu.org/software/gettext/manual/html_node/Header-Entry.html#Header-Entry I think that the translation .po files are generally to be considered as derivative works based on the .pot template file. They are therefore copyrighted by the copyright owners of the .pot template file *and* by the translator(s). Hence, I think it makes sense that the translator(s) may *add* their own copyright notices, if they feel like doing so, but they should _not_ *replace* the original copyright notices with their own notices... Please let me know what you think about my reasoning. Thanks for your time! -- http://www.inventati.org/frx/ There's not a second to spare! To the laboratory! . Francesco Poli . GnuPG key fpr == CA01 1147 9CD2 EFDF FB82 3925 3E1C 27E1 1F69 BFFE pgp5NinsgRSIo.pgp Description: PGP signature
Bug#682580: xgettext: fails to properly replace some placeholders in output .pot (PACKAGE, YEAR, C. HOLDER)
Package: gettext Version: 0.18.1.1-9 Severity: normal Hello! Thanks for maintaining gettext in Debian! I noticed that xgettext does not properly replace all the relevant placeholders in the output .pot file, when told to do so through command-line options. I'll try to explain the issues with a minimal test case. Let's consider the example in the official Python library reference [1]. This should be minimal enough, I think. [1] http://docs.python.org/library/gettext.html#module-gettext Here's the example code: $ cat myapplication.py import gettext gettext.bindtextdomain('myapplication', '/path/to/my/language/directory') gettext.textdomain('myapplication') _ = gettext.gettext # ... print _('This is a translatable string.') Let's generate the corresponding .pot file: $ xgettext --language=python myapplication.py -o myapplication.pot $ cat myapplication.pot # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR EMAIL@ADDRESS, YEAR. # #, fuzzy msgid msgstr Project-Id-Version: PACKAGE VERSION\n Report-Msgid-Bugs-To: \n POT-Creation-Date: 2012-07-23 22:49+0200\n PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n Last-Translator: FULL NAME EMAIL@ADDRESS\n Language-Team: LANGUAGE l...@li.org\n Language: \n MIME-Version: 1.0\n Content-Type: text/plain; charset=CHARSET\n Content-Transfer-Encoding: 8bit\n #: myapplication.py:6 msgid This is a translatable string. msgstr This seems to be OK, but some placeholders should be replaced by actual values. It is my understanding that (before the .pot file is made available to prospective translators who wish to start a localization in a new language) the second line should be replaced by appropriate copyright notices, and that PACKAGE and VERSION should be replaced by the actual package name and version number. Let's try with the following command-line options: $ xgettext --copyright-holder=Python Software Foundation \ --package-name=myapplication --package-version=0.1 \ --language=python myapplication.py -o myapplication2.pot $ cat myapplication2.pot # SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR Python Software Foundation # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR EMAIL@ADDRESS, YEAR. # #, fuzzy msgid msgstr Project-Id-Version: myapplication 0.1\n Report-Msgid-Bugs-To: \n POT-Creation-Date: 2012-07-23 22:49+0200\n PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n Last-Translator: FULL NAME EMAIL@ADDRESS\n Language-Team: LANGUAGE l...@li.org\n Language: \n MIME-Version: 1.0\n Content-Type: text/plain; charset=CHARSET\n Content-Transfer-Encoding: 8bit\n #: myapplication.py:6 msgid This is a translatable string. msgstr $ diff myapplication.pot myapplication2.pot 2c2 # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER --- # Copyright (C) YEAR Python Software Foundation 9c9 Project-Id-Version: PACKAGE VERSION\n --- Project-Id-Version: myapplication 0.1\n That's better, but there are a few issues left: (A) first of all, the YEAR placeholder in the second line is not replaced, and I failed to find an option to do so (B) secondly, I cannot find a way to include multi-line copyright notices, as in [2]: # Copyright (C) 2001-2012 Python Software Foundation. # Copyright (C) 2000 BeOpen.com. # Copyright (C) 1995-2000 Corporation for National Research Initiatives. # Copyright (C) 1991-1995 Stichting Mathematisch Centrum. [2] http://docs.python.org/copyright.html (C) finally, the PACKAGE placeholder is correctly replaced in the Project-Id-Version field, but left untouched in the third line of myapplication2.pot Please fix these issues and/or forward this bug report upstream, as appropriate. Thanks for your time! -- System Information: Debian Release: wheezy/sid APT prefers testing APT policy: (800, 'testing'), (500, 'unstable') Architecture: amd64 (x86_64) Kernel: Linux 3.2.0-3-amd64 (SMP w/2 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/bash Versions of packages gettext depends on: ii dpkg1.16.4.3 ii gettext-base0.18.1.1-9 ii install-info4.13a.dfsg.1-10 ii libasprintf0c2 0.18.1.1-9 ii libc6 2.13-33 ii libcroco3 0.6.5-1 ii libgettextpo0 0.18.1.1-9 ii libglib2.0-02.32.3-1 ii libgomp14.7.1-2 ii libncurses5 5.9-10 ii libtinfo5 5.9-10 ii libunistring0 0.9.3-5 ii libxml2 2.8.0+dfsg1-4 Versions of packages gettext recommends: ii autopoint 0.18.1.1-9 ii curl 7.26.0-1 ii wget 1.13.4-3 Versions of packages gettext suggests: pn gettext-doc none -- no debconf information -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of