download: Don't report the progress too fast.
[jackhill/guix/guix.git] / gnu / packages / gettext.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
3 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
4 ;;; Copyright © 2015, 2017 Ricardo Wurmus <rekado@elephly.net>
5 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2016 Alex Kost <alezost@gmail.com>
7 ;;; Copyright © 2017 Marius Bakke <mbakke@fastmail.com>
8 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
9 ;;;
10 ;;; This file is part of GNU Guix.
11 ;;;
12 ;;; GNU Guix is free software; you can redistribute it and/or modify it
13 ;;; under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 3 of the License, or (at
15 ;;; your option) any later version.
16 ;;;
17 ;;; GNU Guix is distributed in the hope that it will be useful, but
18 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
21 ;;;
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
24
25 (define-module (gnu packages gettext)
26 #:use-module ((guix licenses) #:select (gpl2+ gpl3+))
27 #:use-module (gnu packages)
28 #:use-module (guix packages)
29 #:use-module (guix download)
30 #:use-module (guix build-system gnu)
31 #:use-module (guix build-system perl)
32 #:use-module (gnu packages docbook)
33 #:use-module (gnu packages emacs)
34 #:use-module (gnu packages perl)
35 #:use-module (gnu packages tex)
36 #:use-module (gnu packages xml)
37 #:use-module (guix utils))
38
39 (define-public gettext-minimal
40 (package
41 (name "gettext-minimal")
42 (version "0.19.8.1")
43 (source (origin
44 (method url-fetch)
45 (uri (string-append "mirror://gnu/gettext/gettext-"
46 version ".tar.gz"))
47 (sha256
48 (base32
49 "0hsw28f9q9xaggjlsdp2qmbp2rbd1mp0njzan2ld9kiqwkq2m57z"))
50 ;; test-lock has performance issues on multi-core machines,
51 ;; it hangs or takes a long time to complete.
52 ;; There is one commit in gettext and one commit
53 ;; in gettext's embedded gnulib to fix this issue.
54 (patches (search-patches "gettext-multi-core.patch"
55 "gettext-gnulib-multi-core.patch"))))
56 (build-system gnu-build-system)
57 (outputs '("out"
58 "doc")) ;8 MiB of HTML
59 (inputs
60 `(("expat" ,expat)))
61 (arguments
62 `(#:phases
63 (modify-phases %standard-phases
64 (add-before 'check 'patch-tests
65 (lambda* (#:key inputs #:allow-other-keys)
66 (let* ((bash (which "sh")))
67 ;; Some of the files we're patching are
68 ;; ISO-8859-1-encoded, so choose it as the default
69 ;; encoding so the byte encoding is preserved.
70 (with-fluids ((%default-port-encoding #f))
71 (substitute*
72 (find-files "gettext-tools/tests"
73 "^(lang-sh|msg(exec|filter)-[0-9])")
74 (("#![[:blank:]]/bin/sh")
75 (format #f "#!~a" bash)))
76
77 (substitute* (cons "gettext-tools/src/msginit.c"
78 (find-files "gettext-tools/gnulib-tests"
79 "posix_spawn"))
80 (("/bin/sh")
81 bash))
82
83 (substitute* "gettext-tools/src/project-id"
84 (("/bin/pwd")
85 "pwd"))))))
86 (add-before 'configure 'link-expat
87 (lambda _
88 ;; Gettext defaults to opening expat via dlopen on
89 ;; "Linux". Change to link directly.
90 (substitute* "gettext-tools/configure"
91 (("LIBEXPAT=\"-ldl\"") "LIBEXPAT=\"-ldl -lexpat\"")
92 (("LTLIBEXPAT=\"-ldl\"") "LTLIBEXPAT=\"-ldl -lexpat\"")))))
93
94 ;; When tests fail, we want to know the details.
95 #:make-flags '("VERBOSE=yes")))
96 (home-page "https://www.gnu.org/software/gettext/")
97 (synopsis
98 "Tools and documentation for translation (used to build other packages)")
99 (description
100 "GNU Gettext is a package providing a framework for translating the
101 textual output of programs into multiple languages. It provides translators
102 with the means to create message catalogs, and a runtime library to load
103 translated messages from the catalogs. Nearly all GNU packages use Gettext.")
104 (license gpl3+))) ;some files are under GPLv2+
105
106 ;; Use that name to avoid clashes with Guile's 'gettext' procedure.
107 ;;
108 ;; We used to resort to #:renamer on the user side, but that prevented
109 ;; circular dependencies involving (gnu packages gettext). This is because
110 ;; 'resolve-interface' (as of Guile 2.0.9) iterates eagerly over the used
111 ;; module when there's a #:renamer, and that module may be empty at that point
112 ;; in case or circular dependencies.
113 (define-public gnu-gettext
114 (package
115 (inherit gettext-minimal)
116 (name "gettext")
117 (arguments
118 (substitute-keyword-arguments (package-arguments gettext-minimal)
119 ((#:phases phases)
120 `(modify-phases ,phases
121 (add-after 'install 'add-emacs-autoloads
122 (lambda* (#:key outputs #:allow-other-keys)
123 ;; Make 'po-mode' and other things available by default.
124 (with-directory-excursion
125 (string-append (assoc-ref outputs "out")
126 "/share/emacs/site-lisp")
127 (symlink "start-po.el" "gettext-autoloads.el")
128 #t)))))))
129 (native-inputs `(("emacs" ,emacs-minimal))) ; for Emacs tools
130 (synopsis "Tools and documentation for translation")))
131
132 (define-public po4a
133 (package
134 (name "po4a")
135 (version "0.47")
136 (source (origin
137 (method url-fetch)
138 (uri (string-append "https://alioth.debian.org/frs/download.php"
139 "/file/4142/po4a-" version ".tar.gz"))
140 (sha256
141 (base32
142 "01vm0750aq0h2lphrflv3wq9gz7y0py8frglfpacn58ivyvy242h"))))
143 (build-system perl-build-system)
144 (arguments
145 `(#:phases
146 (modify-phases %standard-phases
147 (add-before 'configure 'set-search-path
148 (lambda _
149 ;; Work around "dotless @INC" build failure.
150 (setenv "PERL5LIB"
151 (string-append (getcwd) ":"
152 (getenv "PERL5LIB")))
153 #t))
154 ;; FIXME: One test fails as we don't have SGMLS.pm
155 (add-before 'check 'disable-sgml-test
156 (lambda _
157 (delete-file "t/20-sgml.t")
158 #t))
159 (add-after 'unpack 'fix-builder
160 (lambda* (#:key inputs outputs #:allow-other-keys)
161 (substitute* "Po4aBuilder.pm"
162 ;; By default it tries to install into perl's manpath.
163 (("my \\$mandir = .*$")
164 (string-append "my $mandir = \"" (assoc-ref outputs "out")
165 "/share/man\";\n")))
166 #t))
167 (add-after 'install 'wrap-programs
168 (lambda* (#:key outputs #:allow-other-keys)
169 ;; Make sure all executables in "bin" find the Perl modules
170 ;; provided by this package at runtime.
171 (let* ((out (assoc-ref outputs "out"))
172 (bin (string-append out "/bin/"))
173 (path (string-append out "/lib/perl5/site_perl")))
174 (for-each (lambda (file)
175 (wrap-program file
176 `("PERL5LIB" ":" prefix (,path))))
177 (find-files bin "\\.*$"))
178 #t)))
179 (add-before 'reset-gzip-timestamps 'make-compressed-files-writable
180 (lambda* (#:key outputs #:allow-other-keys)
181 (for-each make-file-writable
182 (find-files (string-append (assoc-ref outputs "out")
183 "/share/man")
184 ".*\\.gz$"))
185 #t)))))
186 (native-inputs
187 `(("gettext" ,gettext-minimal)
188 ("perl-module-build" ,perl-module-build)
189 ("docbook-xsl" ,docbook-xsl)
190 ("docbook-xml" ,docbook-xml) ;for tests
191 ("texlive" ,texlive-tiny) ;for tests
192 ("libxml2" ,libxml2)
193 ("xsltproc" ,libxslt)))
194 (home-page "http://po4a.alioth.debian.org/")
195 (synopsis "Scripts to ease maintenance of translations")
196 (description
197 "The po4a (PO for anything) project goal is to ease translations (and
198 more interestingly, the maintenance of translations) using gettext tools on
199 areas where they were not expected like documentation.")
200 (license gpl2+)))