Re: [PATCH 1/2] bootstrap: Break automake dependency on generated files. (was Re: Let’s translate!)

2019-04-27 Thread Ludovic Courtès
Hi,

Julien Lepiller  scribes:

> From 77c33ee55115475f582eb49da8dc045432fbdb3b Mon Sep 17 00:00:00 2001
> From: Julien Lepiller 
> Date: Fri, 26 Apr 2019 14:54:52 +0200
> Subject: [PATCH] self: Rebuild translated manuals.
>
> * guix/self.scm (info-manual): Run po4a and related commands to generate
> translated texi files before building translated manuals.
> * guix/build/po.scm: New file.
> * Makefile.am (MODULES): Add it.

I would put po.scm in MODULES_NOT_COMPILED.

> +(define (read-po-file port)
> +  "Read a .po file from PORT and returns an alist of msgid and msgstr."
  ^
“return”

> +(define (translate-texi-manuals source)
> +  "Retrun the translated texinfo manuals built from SOURCE"
 ^   ^
Typos.  :-)

> +  (define (translate-tmp-texi po source tmp-name)
> +(invoke #+(file-append po4a "/bin/po4a-translate")
> +  "-M" "UTF-8" "-L" "UTF-8" "-k" "0" "-f" "texinfo"
> +  "-m" source "-p" po "-l" tmp-name))

I’d remove all the ‘tmp-’ in here since they don’t add anything, and I’d
suggest adding a comment below the ‘define’, like:

  ;; Translate Texinfo file SOURCE using messages from PO, and write the
  ;; result to OUTPUT.

> +  (define (make-ref-regex msgid end)
> +(make-regexp (string-append
> +   "ref\\{" (string-join (string-split msgid #\ ) "[ 
> \n]+")
> +   end)))

The thing in the middle should be wrapped like this:

  (regexp-quote (string-join (string-split …)))

> +  (define (translate-cross-reference content translations)
> +"Take CONTENT, a string representing a .texi file and translate 
> any
> +croos-reference in it (@ref, @xref and @pxref) that have a translation in
 ^^
Typo.

Should be ‘translate-cross-references’ (plural), no?

> +TRANSLATIONS, an alist of msgid and msgstr."
> +   (if (or (equal? msgstr "")
> +   (string-any (lambda (chr)
> + (member chr '(#\{ #\} #\( #\) 
> #\newline #\,)))
> +   msgid))
> + content
> + ;; Otherwise, they might be the name of a section, so we
> + ;; need to translate any occurence in @(p?x?)ref{...}.
> + (let ((regexp1 (make-ref-regex msgid ","))
> +   (regexp2 (make-ref-regex msgid "\\}")))
> +   (regexp-substitute/global
> + #f regexp2
> + (regexp-substitute/global
> +   #f regexp1 content 'pre "ref{" msgstr "," 'post)
> + 'pre "ref{" msgstr "}" 'post))
> +  content translations))

Please align ‘if’ like so:

  (if condition
  then
  else)

You probably need something like this to add (guix build po) to the
result of ‘guix pull’:

diff --git a/guix/self.scm b/guix/self.scm
index 2a10d1d25f..12bc816fa8 100644
--- a/guix/self.scm
+++ b/guix/self.scm
@@ -578,6 +578,7 @@ Info manual."
  ;; us to avoid an extra dependency on guile-gdbm-ffi.
  #:extra-files
  `(("guix/man-db.scm" ,(local-file "../guix/man-db.scm"))
+   ("guix/build/po.scm" ,(local-file "../guix/build/po.scm"))
("guix/store/schema.sql"
 ,(local-file "../guix/store/schema.sql")))
 

Otherwise LGTM!  Please make sure that ‘make as-derivation’ works as
intended (builds the translations, installs (guix build po)) if you
haven’t done it already.

Thanks!

Ludo’.


Re: [PATCH 1/2] bootstrap: Break automake dependency on generated files. (was Re: Let’s translate!)

2019-04-27 Thread Julien Lepiller
Le Sat, 27 Apr 2019 00:10:04 +0200,
Ludovic Courtès  a écrit :

> Hi Julien!
> 
> 
> Could you send an updated patch?
> 
> Thank you!
> 
> Ludo.

Attached is an updated patch.
From 77c33ee55115475f582eb49da8dc045432fbdb3b Mon Sep 17 00:00:00 2001
From: Julien Lepiller 
Date: Fri, 26 Apr 2019 14:54:52 +0200
Subject: [PATCH] self: Rebuild translated manuals.

* guix/self.scm (info-manual): Run po4a and related commands to generate
translated texi files before building translated manuals.
* guix/build/po.scm: New file.
* Makefile.am (MODULES): Add it.
---
 Makefile.am   |   1 +
 guix/build/po.scm |  69 +
 guix/self.scm | 128 +-
 3 files changed, 197 insertions(+), 1 deletion(-)
 create mode 100644 guix/build/po.scm

diff --git a/Makefile.am b/Makefile.am
index 99d6ed64b6..272330c3a9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -156,6 +156,7 @@ MODULES =	\
   guix/build/meson-build-system.scm		\
   guix/build/minify-build-system.scm		\
   guix/build/font-build-system.scm		\
+  guix/build/po.scm\
   guix/build/go-build-system.scm		\
   guix/build/asdf-build-system.scm		\
   guix/build/git.scm\
diff --git a/guix/build/po.scm b/guix/build/po.scm
new file mode 100644
index 00..3fbe9b2373
--- /dev/null
+++ b/guix/build/po.scm
@@ -0,0 +1,69 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2019 Julien Lepiller 
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see .
+
+(define-module (guix build po)
+  #:use-module (ice-9 match)
+  #:use-module (ice-9 peg)
+  #:use-module (ice-9 regex)
+  #:use-module (ice-9 textual-ports)
+  #:export (read-po-file))
+
+;; A small parser for po files
+(define-peg-pattern po-file body (* (or comment entry whitespace)))
+(define-peg-pattern whitespace body (or " " "\t" "\n"))
+(define-peg-pattern comment-chr body (range #\space #\頋))
+(define-peg-pattern comment none (and "#" (* comment-chr) "\n"))
+(define-peg-pattern entry all
+  (and (ignore (* whitespace)) (ignore "msgid ") msgid
+   (ignore (* whitespace)) (ignore "msgstr ") msgstr))
+(define-peg-pattern escape body (or "" "\\\"" "\\n"))
+(define-peg-pattern str-chr body (or " " "!" (and (ignore "\\") "\"")
+ "\\n" (and (ignore "\\") "\\")
+ (range #\# #\頋)))
+(define-peg-pattern msgid all content)
+(define-peg-pattern msgstr all content)
+(define-peg-pattern content body
+  (and (ignore "\"") (* str-chr) (ignore "\"")
+   (? (and (ignore (* whitespace)) content
+
+(define (parse-tree->assoc parse-tree)
+  "Converts a po PARSE-TREE to an association list."
+  (define regex (make-regexp "n"))
+  (match parse-tree
+('() '())
+((entry parse-tree ...)
+ (match entry
+   ((? string? entry)
+(parse-tree->assoc parse-tree))
+   ;; empty msgid
+   (('entry ('msgid ('msgstr msgstr)))
+(parse-tree->assoc parse-tree))
+   ;; empty msgstr
+   (('entry ('msgid msgid) 'msgstr)
+(parse-tree->assoc parse-tree))
+   (('entry ('msgid msgid) ('msgstr msgstr))
+(acons (regexp-substitute/global #f regex msgid 'pre "\n" 'post)
+   (regexp-substitute/global #f regex msgstr 'pre "\n" 'post)
+   (parse-tree->assoc parse-tree)))
+
+(define (read-po-file port)
+  "Read a .po file from PORT and returns an alist of msgid and msgstr."
+  (let ((tree (peg:tree (match-pattern
+  po-file
+  (get-string-all port)
+(parse-tree->assoc tree)))
diff --git a/guix/self.scm b/guix/self.scm
index 2a10d1d25f..3c60da6308 100644
--- a/guix/self.scm
+++ b/guix/self.scm
@@ -60,6 +60,8 @@
   ("gzip"   (ref '(gnu packages compression) 'gzip))
   ("bzip2"  (ref '(gnu packages compression) 'bzip2))
   ("xz" (ref '(gnu packages compression) 'xz))
+  ("po4a"   (ref '(gnu packages gettext) 'po4a))
+  ("gettext"   (ref '(gnu packages gettext) 'gettext-minimal))
   (_#f;no such package
 
 
@@ -253,8 +255,130 @@ DOMAIN, a gettext domain."
   (computed-file (string-append "guix-locale-" domain)
  build))
 
+(define (translate-texi-manuals source)
+  "Retrun the translated texinfo 

Re: [PATCH 1/2] bootstrap: Break automake dependency on generated files. (was Re: Let’s translate!)

2019-04-26 Thread Ludovic Courtès
Hi Julien!

Julien Lepiller  skribis:

> There was an issue introduced by that patch: the manual was not
> generated by guix pull anymore. The attached patch fixes that. WDYT?

Neat!

> From d93644846ff954c221c2510755766da3f0e27b5c Mon Sep 17 00:00:00 2001
> From: Julien Lepiller 
> Date: Fri, 26 Apr 2019 14:54:52 +0200
> Subject: [PATCH] self: Rebuild translated manuals.
>
> * guix/self.scm (info-manual): Run po4a and related commands to generate
> translated texi files before building translated manuals.

[...]

>  (define (info-manual source)
>"Return the Info manual built from SOURCE."

We should probably make a separate derivation (and a separate procedure)
to build the translated Texi files.  Maybe we can think about it later,
though.

>  (with-imported-modules '((guix build utils))
>#~(begin
>(use-modules (guix build utils))
> +  (use-modules (ice-9 match))
> +  (use-modules (ice-9 peg))
> +  (use-modules (ice-9 regex))
> +  (use-modules (ice-9 textual-ports))
> +  (use-modules (srfi srfi-1))

Please make it a single use-modules:

  (use-modules (a b c) (x y z) &)

> +  ;; A small parser for po files
> +  (define-peg-pattern po-file body (* (or comment entry whitespace)))
> +  (define-peg-pattern whitespace body (or " " "\t" "\n"))
> +  (define-peg-pattern comment-chr body (range #\space #\.¿))
> +  (define-peg-pattern comment none (and "#" (* comment-chr) "\n"))
> +  (define-peg-pattern entry all
> +(and (ignore (* whitespace)) (ignore "msgid ") msgid
> + (ignore (* whitespace)) (ignore "msgstr ") msgstr))
> +  (define-peg-pattern escape body (or "" "\\\"" "\\n"))
> +  (define-peg-pattern str-chr body (or " " "!" (and (ignore "\\") 
> "\"")
> +   "\\n" (and (ignore "\\") "\\")
> +   (range #\# #\.¿)))
> +  (define-peg-pattern msgid all content)
> +  (define-peg-pattern msgstr all content)
> +  (define-peg-pattern content body
> +(and (ignore "\"") (* str-chr) (ignore "\"")
> + (? (and (ignore (* whitespace)) content
> +  
> +  (define (parse-tree->assoc parse-tree)
> +"Converts a po PARSE-TREE to an association list."
> +(define regex (make-regexp "n"))
> +(match parse-tree
> +  ('() '())
> +  ((entry parse-tree ...)
> +   (match entry
> + ((? string? entry)
> +  (parse-tree->assoc parse-tree))
> + ;; empty msgid
> + (('entry ('msgid ('msgstr msgstr)))
> +  (parse-tree->assoc parse-tree))
> + ;; empty msgstr
> + (('entry ('msgid msgid) 'msgstr)
> +  (parse-tree->assoc parse-tree))
> + (('entry ('msgid msgid) ('msgstr msgstr))
> +  (acons (regexp-substitute/global #f regex msgid 'pre "\n" 
> 'post)
> + (regexp-substitute/global #f regex msgstr 'pre "\n" 
> 'post)
> + (parse-tree->assoc parse-tree)))

What about moving all this to (guix build po) or similar?  It would
export read-po-file, which takes an input port and returns an alist of
message ID/translations.  I dont want to think about parse trees as a
user of the API.  :-)

> +  (define (create-texi po source texi-name)

This function is too long, could you split it?
Maybe it should be called translate-texi?

> +(let* ((parse-tree
> + (peg:tree (match-pattern
> + po-file
> + (call-with-input-file po get-string-all
> +   (translations (parse-tree->assoc parse-tree))
> +   (tmp-name (string-append texi-name ".tmp")))
> +  (setenv "PATH" #+(file-append gettext "/bin"))
> +  (invoke #+(file-append po4a "/bin/po4a-translate")
> +"-M" "UTF-8" "-L" "UTF-8" "-k" "0" "-f" "texinfo"
> +"-m" source "-p" po "-l" tmp-name)
> +  (with-output-to-file texi-name
> +(lambda _
> +  (format #t "~a"
> +(fold
> +  (lambda (elem content)
> +(let* ((msgid (car elem))
> +   (msgstr (cdr elem)))

Please use match.

> +  (if (or (equal? msgstr "")
> +  (string-any (lambda (chr)
> +(member chr '(#\{ #\} #\( #\)
> +  #\newline 
> #\,)))
> +  msgid))
> +content
> +(let ((regexp1
> 

Re: [PATCH 1/2] bootstrap: Break automake dependency on generated files. (was Re: Let’s translate!)

2019-04-26 Thread Julien Lepiller
Le Fri, 26 Apr 2019 13:05:14 +0200,
Miguel  a écrit :

> Hi,
> 
> El Fri, 26 Apr 2019 11:30:04 +0200
> Julien Lepiller  escribió:
> > Thank you! I've just pushed it and removed doc/guix.*.texi and
> > doc/contributing.*.texi from the repository, added them
> > to .gitignore too.  
> 
> Thank you very much, my emacs and magit will thank you too, as each
> change in the manual was taking awfully long to refresh. :)
> 
> Best regards,
> Miguel

There was an issue introduced by that patch: the manual was not
generated by guix pull anymore. The attached patch fixes that. WDYT?
From d93644846ff954c221c2510755766da3f0e27b5c Mon Sep 17 00:00:00 2001
From: Julien Lepiller 
Date: Fri, 26 Apr 2019 14:54:52 +0200
Subject: [PATCH] self: Rebuild translated manuals.

* guix/self.scm (info-manual): Run po4a and related commands to generate
translated texi files before building translated manuals.
---
 guix/self.scm | 116 +-
 1 file changed, 115 insertions(+), 1 deletion(-)

diff --git a/guix/self.scm b/guix/self.scm
index 2a10d1d25f..89d3212f52 100644
--- a/guix/self.scm
+++ b/guix/self.scm
@@ -60,6 +60,8 @@
   ("gzip"   (ref '(gnu packages compression) 'gzip))
   ("bzip2"  (ref '(gnu packages compression) 'bzip2))
   ("xz" (ref '(gnu packages compression) 'xz))
+  ("po4a"   (ref '(gnu packages gettext) 'po4a))
+  ("gettext"   (ref '(gnu packages gettext) 'gettext-minimal))
   (_#f;no such package
 
 
@@ -255,6 +257,12 @@ DOMAIN, a gettext domain."
 
 (define (info-manual source)
   "Return the Info manual built from SOURCE."
+  (define po4a
+(specification->package "po4a"))
+
+  (define gettext
+(specification->package "gettext"))
+
   (define texinfo
 (module-ref (resolve-interface '(gnu packages texinfo))
 'texinfo))
@@ -270,6 +278,9 @@ DOMAIN, a gettext domain."
   (define documentation
 (file-append* source "doc"))
 
+  (define documentation-po
+(file-append* source "po/doc"))
+
   (define examples
 (file-append* source "gnu/system/examples"))
 
@@ -277,6 +288,49 @@ DOMAIN, a gettext domain."
 (with-imported-modules '((guix build utils))
   #~(begin
   (use-modules (guix build utils))
+  (use-modules (ice-9 match))
+  (use-modules (ice-9 peg))
+  (use-modules (ice-9 regex))
+  (use-modules (ice-9 textual-ports))
+  (use-modules (srfi srfi-1))
+  
+  ;; A small parser for po files
+  (define-peg-pattern po-file body (* (or comment entry whitespace)))
+  (define-peg-pattern whitespace body (or " " "\t" "\n"))
+  (define-peg-pattern comment-chr body (range #\space #\頋))
+  (define-peg-pattern comment none (and "#" (* comment-chr) "\n"))
+  (define-peg-pattern entry all
+(and (ignore (* whitespace)) (ignore "msgid ") msgid
+ (ignore (* whitespace)) (ignore "msgstr ") msgstr))
+  (define-peg-pattern escape body (or "" "\\\"" "\\n"))
+  (define-peg-pattern str-chr body (or " " "!" (and (ignore "\\") "\"")
+   "\\n" (and (ignore "\\") "\\")
+   (range #\# #\頋)))
+  (define-peg-pattern msgid all content)
+  (define-peg-pattern msgstr all content)
+  (define-peg-pattern content body
+(and (ignore "\"") (* str-chr) (ignore "\"")
+ (? (and (ignore (* whitespace)) content
+  
+  (define (parse-tree->assoc parse-tree)
+"Converts a po PARSE-TREE to an association list."
+(define regex (make-regexp "n"))
+(match parse-tree
+  ('() '())
+  ((entry parse-tree ...)
+   (match entry
+ ((? string? entry)
+  (parse-tree->assoc parse-tree))
+ ;; empty msgid
+ (('entry ('msgid ('msgstr msgstr)))
+  (parse-tree->assoc parse-tree))
+ ;; empty msgstr
+ (('entry ('msgid msgid) 'msgstr)
+  (parse-tree->assoc parse-tree))
+ (('entry ('msgid msgid) ('msgstr msgstr))
+  (acons (regexp-substitute/global #f regex msgid 'pre "\n" 'post)
+ (regexp-substitute/global #f regex msgstr 'pre "\n" 'post)
+ (parse-tree->assoc parse-tree)))
 
   (mkdir #$output)
 
@@ -322,11 +376,15 @@ DOMAIN, a gettext domain."
 (find-files (string-append #$documentation "/images")
 "\\.png$"))
 
-  ;; Finally build the manual.  Copy it the Texinfo files to $PWD and
+  ;; Finally build the manual.  Copy it the Texinfo and po files to $PWD and
   ;; add a symlink to the 'images' directory so that 'makeinfo' can
   

Re: [PATCH 1/2] bootstrap: Break automake dependency on generated files. (was Re: Let’s translate!)

2019-04-26 Thread Miguel
Hi,

El Fri, 26 Apr 2019 11:30:04 +0200
Julien Lepiller  escribió:
> Thank you! I've just pushed it and removed doc/guix.*.texi and
> doc/contributing.*.texi from the repository, added them to .gitignore
> too.

Thank you very much, my emacs and magit will thank you too, as each
change in the manual was taking awfully long to refresh. :)

Best regards,
Miguel



Re: [PATCH 1/2] bootstrap: Break automake dependency on generated files. (was Re: Let’s translate!)

2019-04-26 Thread Julien Lepiller
Le Tue, 23 Apr 2019 12:28:10 +0200,
Miguel  a écrit :

> Hi Julien,
> 
> First of all, thank you for your work.
> 
> El Tue, 23 Apr 2019 09:28:19 +0200
> Julien Lepiller  escribió:
> > This is a very good idea, but I think it leaves a stub texi that
> > won't get rebuilt because it's younger than po files.   
> 
> Yes, you are right indeed. I didn't noticed because I was updating
> the .po file manually.
> 
> > What if we add a toucgh invocation to reset the modification time
> > of these stubs, to ensure make will want to rebuild them?  
> 
> What about the attached patch? I've just tested it with the other
> patch that seems to be missing or blocked by its size, nothing up my
> sleeves this time. 0:-)
> 
> Best regards,
> Miguel

Thank you! I've just pushed it and removed doc/guix.*.texi and
doc/contributing.*.texi from the repository, added them to .gitignore
too.



Re: [PATCH 1/2] bootstrap: Break automake dependency on generated files. (was Re: Let’s translate!)

2019-04-26 Thread Ludovic Courtès
Salut Julien,

Julien Lepiller  skribis:

> Le 25 avril 2019 10:50:16 GMT+02:00, "Ludovic Courtès"  a écrit 
> :

[...]

>>> You will only be bothered when new translations appear, in which case
>>> you'll have to run ./bootstrap again, but on the other hand, you will
>>> never be bothered by *.texi files being changed all the time.
>>
>>So what would one have to do when preparing a new release?  Presumably
>>nothing because the up-to-date texi files would be checked in?
>>
>>IOW, running ./bootstrap is something what would matter primarily to
>>translators, is that correct?
>
> It would be needed to build the translated manuals, so I think it would be 
> needed to successfuly run make from the git checkout. Translators should not 
> even care about the source. Or maybe running only autoreconf will simply not 
> build the translated manuals, I'm not sure.
>
> But once you run ./bootstrap once, you should not have to run it again until 
> a new language is available for the manual.

I see, sounds good to me.

I think you can go ahead and push!

Thanks for explaining,
Ludo’.



Re: [PATCH 1/2] bootstrap: Break automake dependency on generated files. (was Re: Let’s translate!)

2019-04-25 Thread Julien Lepiller
Le 25 avril 2019 10:50:16 GMT+02:00, "Ludovic Courtès"  a écrit :
>Hello,
>
>Julien Lepiller  skribis:
>
>> Le Wed, 24 Apr 2019 00:51:37 +0200,
>> Miguel  a écrit :
>
>[...]
>
>>> El Tue, 23 Apr 2019 16:30:26 +0200
>>> Ludovic Courtès  escribió:
>
>>> > Also, I don’t actually use the ./bootstrap script.  :-)  
>>> 
>>> Currently it is only a call to autoreconf -fvi, but it's there for a
>>> reason, isn't it?
>
>It’s there mostly because people are used to having such a file, but I
>like the fact that it does nothing magical.
>
>> I actually agree with Miguel here. The phony target would not allow
>us
>> to update the manual. It's probably a matter of preferences, but I
>> prefer an up to date manual with some English sentences than a fully
>> translated but outdated manual. I wouldn't use a manual that could
>> refer to an older version.
>
>I agree that up-to-date is preferable.
>
>> You will only be bothered when new translations appear, in which case
>> you'll have to run ./bootstrap again, but on the other hand, you will
>> never be bothered by *.texi files being changed all the time.
>
>So what would one have to do when preparing a new release?  Presumably
>nothing because the up-to-date texi files would be checked in?
>
>IOW, running ./bootstrap is something what would matter primarily to
>translators, is that correct?

It would be needed to build the translated manuals, so I think it would be 
needed to successfuly run make from the git checkout. Translators should not 
even care about the source. Or maybe running only autoreconf will simply not 
build the translated manuals, I'm not sure.

But once you run ./bootstrap once, you should not have to run it again until a 
new language is available for the manual.

>
>Thanks,
>Ludo’.




Re: [PATCH 1/2] bootstrap: Break automake dependency on generated files. (was Re: Let’s translate!)

2019-04-25 Thread Ludovic Courtès
Hello,

Julien Lepiller  skribis:

> Le Wed, 24 Apr 2019 00:51:37 +0200,
> Miguel  a écrit :

[...]

>> El Tue, 23 Apr 2019 16:30:26 +0200
>> Ludovic Courtès  escribió:

>> > Also, I don’t actually use the ./bootstrap script.  :-)  
>> 
>> Currently it is only a call to autoreconf -fvi, but it's there for a
>> reason, isn't it?

It’s there mostly because people are used to having such a file, but I
like the fact that it does nothing magical.

> I actually agree with Miguel here. The phony target would not allow us
> to update the manual. It's probably a matter of preferences, but I
> prefer an up to date manual with some English sentences than a fully
> translated but outdated manual. I wouldn't use a manual that could
> refer to an older version.

I agree that up-to-date is preferable.

> You will only be bothered when new translations appear, in which case
> you'll have to run ./bootstrap again, but on the other hand, you will
> never be bothered by *.texi files being changed all the time.

So what would one have to do when preparing a new release?  Presumably
nothing because the up-to-date texi files would be checked in?

IOW, running ./bootstrap is something what would matter primarily to
translators, is that correct?

Thanks,
Ludo’.



Re: [PATCH 1/2] bootstrap: Break automake dependency on generated files. (was Re: Let’s translate!)

2019-04-24 Thread Julien Lepiller
Le Wed, 24 Apr 2019 00:51:37 +0200,
Miguel  a écrit :

> Hi,
> 
> El Tue, 23 Apr 2019 16:30:26 +0200
> Ludovic Courtès  escribió:
> > Hello,
> > 
> > Julien Lepiller  skribis:
> >   
> > > This is a very good idea, but I think it leaves a stub texi that
> > > won't get rebuilt because it's younger than po files. What if we
> > > add a toucgh invocation to reset the modification time of these
> > > stubs, to ensure make will want to rebuild them?
> > 
> > Also, I don’t actually use the ./bootstrap script.  :-)  
> 
> Currently it is only a call to autoreconf -fvi, but it's there for a
> reason, isn't it?
> 
> > Shouldn’t we instead replace the existing %.texi targets in
> > doc/local.mk with a phony target like ‘update-texi’, and then add:
> > 
> >   dist-hook: update-texi
> > 
> > ?  
> 
> The procedure needed currently to a new translation for the manual is:
>   1. modify doc/local.mk, po/doc/local.mk and so on. 
>   2. guix.LL.texi must be manually generated somehow even though it is
>   listed in BUILT_SOURCES.
>   3. automake can run without errors with the rules in order to
> generate the actual translated file.
>   4. The resulting files are committed.
> 
> The problem is that automake parses .texi files for the @setfilename
> tag. On the other hand, guix.LL.texi and contributing.LL.texi are
> generated files, and they shouldn't be on the VCS, just like neither
> configure nor Makefile.in are, though they are distributed. My patch
> tries to avoid this issue creating stub files that will be overwritten
> with the actual content. This has the advantage of keeping clean git
> status from other modifications than .po files changes.
> 
> This may sound familiar to this community, it actually is a bootstrap
> problem. Running autoreconf -fvi actually tells you that that file is
> missing, so that part is easy to fix. On the other hand, as far as I
> tested if it does not contain a line with version-LL.texi,
> version-LL.texi won't be generated.
> 
> Happy hacking,
> Miguel

I actually agree with Miguel here. The phony target would not allow us
to update the manual. It's probably a matter of preferences, but I
prefer an up to date manual with some English sentences than a fully
translated but outdated manual. I wouldn't use a manual that could
refer to an older version.

Also Miguel's solution looks a lot more clean in the bootstrapping
point of view, and I think this is a strong argument in this
community :)

You will only be bothered when new translations appear, in which case
you'll have to run ./bootstrap again, but on the other hand, you will
never be bothered by *.texi files being changed all the time.



Re: [PATCH 1/2] bootstrap: Break automake dependency on generated files. (was Re: Let’s translate!)

2019-04-23 Thread Miguel
Hi,

El Tue, 23 Apr 2019 16:30:26 +0200
Ludovic Courtès  escribió:
> Hello,
> 
> Julien Lepiller  skribis:
> 
> > This is a very good idea, but I think it leaves a stub texi that
> > won't get rebuilt because it's younger than po files. What if we
> > add a toucgh invocation to reset the modification time of these
> > stubs, to ensure make will want to rebuild them?  
> 
> Also, I don’t actually use the ./bootstrap script.  :-)

Currently it is only a call to autoreconf -fvi, but it's there for a
reason, isn't it?

> Shouldn’t we instead replace the existing %.texi targets in
> doc/local.mk with a phony target like ‘update-texi’, and then add:
> 
>   dist-hook: update-texi
> 
> ?

The procedure needed currently to a new translation for the manual is:
  1. modify doc/local.mk, po/doc/local.mk and so on. 
  2. guix.LL.texi must be manually generated somehow even though it is
  listed in BUILT_SOURCES.
  3. automake can run without errors with the rules in order to generate
  the actual translated file.
  4. The resulting files are committed.

The problem is that automake parses .texi files for the @setfilename
tag. On the other hand, guix.LL.texi and contributing.LL.texi are
generated files, and they shouldn't be on the VCS, just like neither
configure nor Makefile.in are, though they are distributed. My patch
tries to avoid this issue creating stub files that will be overwritten
with the actual content. This has the advantage of keeping clean git
status from other modifications than .po files changes.

This may sound familiar to this community, it actually is a bootstrap
problem. Running autoreconf -fvi actually tells you that that file is
missing, so that part is easy to fix. On the other hand, as far as I
tested if it does not contain a line with version-LL.texi,
version-LL.texi won't be generated.

Happy hacking,
Miguel



Re: [PATCH 1/2] bootstrap: Break automake dependency on generated files. (was Re: Let’s translate!)

2019-04-23 Thread Ludovic Courtès
Hello,

Julien Lepiller  skribis:

> This is a very good idea, but I think it leaves a stub texi that won't get 
> rebuilt because it's younger than po files. What if we add a toucgh 
> invocation to reset the modification time of these stubs, to ensure make will 
> want to rebuild them?

Also, I don’t actually use the ./bootstrap script.  :-)

Shouldn’t we instead replace the existing %.texi targets in doc/local.mk
with a phony target like ‘update-texi’, and then add:

  dist-hook: update-texi

?

This would be similar to the ‘update-po’ rule generated by Gettext in
po/.

Thanks,
Ludo’.



Re: [PATCH 1/2] bootstrap: Break automake dependency on generated files. (was Re: Let’s translate!)

2019-04-23 Thread Miguel
Hi Julien,

First of all, thank you for your work.

El Tue, 23 Apr 2019 09:28:19 +0200
Julien Lepiller  escribió:
> This is a very good idea, but I think it leaves a stub texi that
> won't get rebuilt because it's younger than po files. 

Yes, you are right indeed. I didn't noticed because I was updating
the .po file manually.

> What if we add a toucgh invocation to reset the modification time
> of these stubs, to ensure make will want to rebuild them?

What about the attached patch? I've just tested it with the other
patch that seems to be missing or blocked by its size, nothing up my
sleeves this time. 0:-)

Best regards,
Miguel
>From fe873d65dd5795bdafc9eed66888f7d2e9bf6b4c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miguel=20=C3=81ngel=20Arruga=20Vivas?=
 
Date: Tue, 23 Apr 2019 11:30:32 +0200
Subject: [PATCH 1/4] bootstrap: Break automake dependency on generated files.

* bootstrap: Generate stub files for the manual translations whose
generated files are not included in the VCS.
---
 bootstrap | 14 ++
 1 file changed, 14 insertions(+)

diff --git a/bootstrap b/bootstrap
index cb774bc737..c0b5af7677 100755
--- a/bootstrap
+++ b/bootstrap
@@ -2,4 +2,18 @@
 # Create the build system.
 
 set -e -x
+
+# Generate stubs for translations.
+langs=`find po/doc -type f -name '*.po' \
+| sed -e 's,guix-manual\.,,' \
+| xargs -n 1 -I{} basename {} .po`
+for lang in ${langs}; do
+if [ ! -e "doc/guix.${lang}.texi" ]; then
+	echo "@setfilename guix.${lang}.info" > "doc/guix.${lang}.texi"
+	echo "@include version-${lang}.texi" >> "doc/guix.${lang}.texi"
+	# Ensure .po file is newer.
+	touch "po/doc/guix-manual.${lang}.po"
+fi
+done
+
 exec autoreconf -vfi
-- 
2.21.0



Re: [PATCH 1/2] bootstrap: Break automake dependency on generated files. (was Re: Let’s translate!)

2019-04-23 Thread Julien Lepiller
Le 23 avril 2019 02:43:42 GMT+02:00, Miguel  a écrit :
>

This is a very good idea, but I think it leaves a stub texi that won't get 
rebuilt because it's younger than po files. What if we add a toucgh invocation 
to reset the modification time of these stubs, to ensure make will want to 
rebuild them?



[PATCH 1/2] bootstrap: Break automake dependency on generated files. (was Re: Let’s translate!)

2019-04-22 Thread Miguel
>From c5ed65b04c412a97674dd9129a0cac10500fdf7a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Miguel=20=C3=81ngel=20Arruga=20Vivas?=
 
Date: Tue, 23 Apr 2019 00:21:44 +0200
Subject: [PATCH 1/2] bootstrap: Break automake dependency on generated files.

* bootstrap: Generate stub files for the manual translations whose
generated files are not included in the VCS.
---
 bootstrap | 12 
 1 file changed, 12 insertions(+)

diff --git a/bootstrap b/bootstrap
index cb774bc737..62f6cb0fab 100755
--- a/bootstrap
+++ b/bootstrap
@@ -2,4 +2,16 @@
 # Create the build system.
 
 set -e -x
+
+# Generate stubs for translations.
+langs=`find po/doc -type f -name '*.po' \
+| sed -e 's,guix-manual\.,,' \
+| xargs -n 1 -I{} basename {} .po`
+for lang in ${langs}; do
+if [ ! -e "doc/guix.${lang}.texi" ]; then
+	echo "@setfilename guix.${lang}.info" > "doc/guix.${lang}.texi"
+	echo "@include version-${lang}.texi" >> "doc/guix.${lang}.texi"
+fi
+done
+
 exec autoreconf -vfi
-- 
2.21.0