From 84c37e636804513f1fde1fe437784400d99e268e Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 21 Apr 2020 22:23:54 +0200 Subject: 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. --- guix/self.scm | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/guix/self.scm b/guix/self.scm index 93dcb9bee3..3cc1003c3a 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -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) -- cgit v1.2.3