self: translate-texi-manuals: Add 'available-translations'.

* guix/self.scm (translate-texi-manuals)[build](available-translations):
New procedure.
Use it rather than directly calling 'find-files' & co.
This commit is contained in:
Ludovic Courtès 2020-04-21 22:23:54 +02:00
parent cc753650ec
commit 84c37e6368
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
1 changed files with 19 additions and 6 deletions

View File

@ -363,12 +363,25 @@ a list of extra files, such as '(\"contributing\")."
translations))))))
(cons prefix extras))))
(for-each (lambda (po)
(match (reverse (string-split po #\.))
((_ lang _ ...)
(translate-texi "guix" po lang
#:extras '("contributing")))))
(find-files "." "^guix-manual\\.[a-z]{2}(_[A-Z]{2})?\\.po$"))
(define (available-translations directory domain)
;; Return the list of available translations under DIRECTORY for
;; DOMAIN, a gettext domain such as "guix-manual". The result is
;; a list of language/PO file pairs.
(filter-map (lambda (po)
(let ((base (basename po)))
(and (string-prefix? (string-append domain ".")
base)
(match (string-split base #\.)
((_ ... lang "po")
(cons lang po))))))
(find-files directory
"\\.[a-z]{2}(_[A-Z]{2})?\\.po$")))
(for-each (match-lambda
((language . po)
(translate-texi "guix" po language
#:extras '("contributing"))))
(available-translations "." "guix-manual"))
(for-each
(lambda (file)