gnu: Simplify package inputs.
[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, 2019 Efraim Flashner <efraim@flashner.co.il>
6 ;;; Copyright © 2016 Alex Kost <alezost@gmail.com>
7 ;;; Copyright © 2017, 2019, 2020 Marius Bakke <marius@gnu.org>
8 ;;; Copyright © 2017 Mathieu Othacehe <m.othacehe@gmail.com>
9 ;;; Copyright © 2017 Eric Bavier <bavier@member.fsf.org>
10 ;;; Copyright © 2018, 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
11 ;;; Copyright © 2019 Miguel <rosen644835@gmail.com>
12 ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
13 ;;; Copyright © 2020 EuAndreh <eu@euandre.org>
14 ;;;
15 ;;; This file is part of GNU Guix.
16 ;;;
17 ;;; GNU Guix is free software; you can redistribute it and/or modify it
18 ;;; under the terms of the GNU General Public License as published by
19 ;;; the Free Software Foundation; either version 3 of the License, or (at
20 ;;; your option) any later version.
21 ;;;
22 ;;; GNU Guix is distributed in the hope that it will be useful, but
23 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
24 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 ;;; GNU General Public License for more details.
26 ;;;
27 ;;; You should have received a copy of the GNU General Public License
28 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
29
30 (define-module (gnu packages gettext)
31 #:use-module ((guix licenses) #:select (gpl2+ gpl3+ bsd-3))
32 #:use-module (gnu packages)
33 #:use-module (guix packages)
34 #:use-module (guix download)
35 #:use-module (guix build-system gnu)
36 #:use-module (guix build-system perl)
37 #:use-module (guix build-system python)
38 #:use-module (gnu packages check)
39 #:use-module (gnu packages docbook)
40 #:use-module (gnu packages emacs)
41 #:use-module (gnu packages hurd)
42 #:use-module (gnu packages libunistring)
43 #:use-module (gnu packages ncurses)
44 #:use-module (gnu packages perl)
45 #:use-module (gnu packages perl-check)
46 #:use-module (gnu packages tex)
47 #:use-module (gnu packages xml)
48 #:use-module (gnu packages python-xyz)
49 #:use-module (gnu packages sphinx)
50 #:use-module (guix utils))
51
52 (define-public gettext-minimal
53 (package
54 (name "gettext-minimal")
55 (version "0.21")
56 (source (origin
57 (method url-fetch)
58 (uri (string-append "mirror://gnu/gettext/gettext-"
59 version ".tar.gz"))
60 (sha256
61 (base32
62 "04kbg1sx0ncfrsbr85ggjslqkzzb243fcw9nyh3rrv1a22ihszf7"))))
63 (build-system gnu-build-system)
64 (outputs '("out"
65 "doc")) ;9 MiB of HTML
66 (inputs
67 (list libunistring
68 libxml2
69 ;; TODO: ncurses is only needed for the 'libtextstyle' library.
70 ;; The next version of gettext can use a separate libtextstyle,
71 ;; but for now we include it here in 'gettext-minimal'.
72 ncurses))
73 (arguments
74 `(#:configure-flags '("--with-included-libunistring=no"
75 "--with-included-libxml=no")
76 #:phases
77 (modify-phases %standard-phases
78 (add-before 'patch-source-shebangs 'patch-fixed-paths
79 (lambda _
80 (substitute* '("gettext-tools/config.h.in"
81 "gettext-tools/gnulib-tests/init.sh"
82 "gettext-tools/tests/init.sh"
83 "gettext-tools/system-tests/run-test")
84 (("/bin/sh") "sh"))
85 (substitute* '("gettext-tools/src/project-id"
86 "gettext-tools/projects/KDE/trigger"
87 "gettext-tools/projects/GNOME/trigger")
88 (("/bin/pwd") "pwd"))
89 #t))
90 (add-before 'check 'patch-tests
91 (lambda* (#:key inputs #:allow-other-keys)
92 (let* ((bash (which "sh")))
93 ;; Some of the files we're patching are
94 ;; ISO-8859-1-encoded, so choose it as the default
95 ;; encoding so the byte encoding is preserved.
96 (with-fluids ((%default-port-encoding #f))
97 (substitute*
98 (find-files "gettext-tools/tests"
99 "^(lang-sh|msg(exec|filter)-[0-9])")
100 (("#![[:blank:]]/bin/sh")
101 (format #f "#!~a" bash)))
102
103 (substitute* (cons "gettext-tools/src/msginit.c"
104 (find-files "gettext-tools/gnulib-tests"
105 "posix_spawn"))
106 (("/bin/sh")
107 bash))
108
109 (substitute* "gettext-tools/src/project-id"
110 (("/bin/pwd")
111 "pwd"))
112
113 #t)))))
114
115 ;; When tests fail, we want to know the details.
116 #:make-flags '("VERBOSE=yes"
117 ,@(if (hurd-target?)
118 ;; Linking to libgettextlib.so makes test-raise fail
119 '("XFAIL_TESTS=test-raise")
120 '()))))
121 (home-page "https://www.gnu.org/software/gettext/")
122 (synopsis
123 "Tools and documentation for translation (used to build other packages)")
124 (description
125 "GNU Gettext is a package providing a framework for translating the
126 textual output of programs into multiple languages. It provides translators
127 with the means to create message catalogs, and a runtime library to load
128 translated messages from the catalogs. Nearly all GNU packages use Gettext.")
129 (properties `((upstream-name . "gettext")
130 (cpe-name . "gettext")))
131 (license gpl3+))) ;some files are under GPLv2+
132
133 ;; Use that name to avoid clashes with Guile's 'gettext' procedure.
134 ;;
135 ;; We used to resort to #:renamer on the user side, but that prevented
136 ;; circular dependencies involving (gnu packages gettext). This is because
137 ;; 'resolve-interface' (as of Guile 2.0.9) iterates eagerly over the used
138 ;; module when there's a #:renamer, and that module may be empty at that point
139 ;; in case or circular dependencies.
140 (define-public gnu-gettext
141 (package/inherit gettext-minimal
142 (name "gettext")
143 (arguments
144 (substitute-keyword-arguments (package-arguments gettext-minimal)
145 ((#:phases phases)
146 `(modify-phases ,phases
147 (add-after 'install 'add-emacs-autoloads
148 (lambda* (#:key outputs #:allow-other-keys)
149 ;; Make 'po-mode' and other things available by default.
150 (with-directory-excursion
151 (string-append (assoc-ref outputs "out")
152 "/share/emacs/site-lisp")
153 (symlink "start-po.el" "gettext-autoloads.el")
154 #t)))))))
155 (native-inputs `(("emacs" ,emacs-minimal))) ; for Emacs tools
156 (synopsis "Tools and documentation for translation")))
157
158 (define-public libtextstyle
159 (package
160 (name "libtextstyle")
161 (version "0.21")
162 (source (origin
163 (inherit (package-source gnu-gettext))
164 (uri (string-append "mirror://gnu/gettext/gettext-"
165 version ".tar.gz"))
166 (sha256
167 (base32
168 "04kbg1sx0ncfrsbr85ggjslqkzzb243fcw9nyh3rrv1a22ihszf7"))))
169 (build-system gnu-build-system)
170 (arguments
171 '(#:configure-flags '("--disable-static")
172 #:phases (modify-phases %standard-phases
173 (add-after 'unpack 'chdir
174 (lambda _
175 (chdir "libtextstyle")
176 #t)))))
177 ;; libtextstyle bundles libxml2, glib (a small subset thereof), and
178 ;; libcroco, but it purposefully prevents users from using an external
179 ;; copy, to reduce the startup time of programs using libtextstyle.
180 (home-page "https://www.gnu.org/software/gettext/")
181 (synopsis "Text styling library")
182 (description
183 "GNU libtextstyle is a C library that provides an easy way to add styling
184 to programs that produce output to a console or terminal emulator window. It
185 allows applications to emit text annotated with styling information, such as
186 color, font attributes (weight, posture), or underlining.")
187 (license gpl3+)))
188
189 (define-public mdpo
190 (package
191 (name "mdpo")
192 (version "0.3.6")
193 (source
194 (origin
195 (method url-fetch)
196 (uri (pypi-uri "mdpo" version))
197 (sha256
198 (base32 "0kgbm0af7jwpfspa2xxiy9nc2l1r2s1rhbhz4r229zcqv49ak6sq"))))
199 (build-system python-build-system)
200 (native-inputs
201 (list python-bump2version
202 python-flake8
203 python-flake8-implicit-str-concat
204 python-flake8-print
205 python-isort
206 python-pre-commit
207 python-pytest
208 python-pytest-cov
209 python-sphinx
210 python-sphinx-argparse
211 python-sphinx-rtd-theme
212 python-twine
213 python-yamllint))
214 (propagated-inputs
215 (list python-polib python-pymd4c))
216 (home-page "https://github.com/mondeja/mdpo")
217 (synopsis "Markdown file translation utilities using pofiles")
218 (description
219 "The mdpo utility creates pofiles, the format stabilished by GNU Gettext,
220 from Markdown files.")
221 (license bsd-3)))
222
223 (define-public po4a
224 (package
225 (name "po4a")
226 (version "0.63")
227 (source (origin
228 (method url-fetch)
229 (uri (string-append "https://github.com/mquinson/po4a/releases/download/v"
230 version "/po4a-" version ".tar.gz"))
231 (sha256
232 (base32
233 "1kmlfpdl1i1wrcdn0k1frh44fq10sfwswi3azvibli2lakpf66z2"))))
234 (build-system perl-build-system)
235 (arguments
236 `(#:phases
237 (modify-phases %standard-phases
238 (add-after 'install 'wrap-programs
239 (lambda* (#:key inputs outputs #:allow-other-keys)
240 ;; Make sure all executables in "bin" find the Perl modules
241 ;; required by this package at runtime.
242 (let* ((out (assoc-ref outputs "out"))
243 (bin (string-append out "/bin/"))
244 (Pod::Parser (assoc-ref inputs "perl-pod-parser"))
245 (path (string-append out "/lib/perl5/site_perl:"
246 Pod::Parser "/lib/perl5/site_perl")))
247 (for-each (lambda (file)
248 (wrap-program file
249 `("PERL5LIB" ":" prefix (,path))))
250 (find-files bin "\\.*$"))
251 #t)))
252 (add-before 'reset-gzip-timestamps 'make-compressed-files-writable
253 (lambda* (#:key outputs #:allow-other-keys)
254 (for-each make-file-writable
255 (find-files (string-append (assoc-ref outputs "out")
256 "/share/man")
257 ".*\\.gz$"))
258 #t))
259 (add-after 'unpack 'patch-docbook-xml
260 (lambda* (#:key inputs #:allow-other-keys)
261 (substitute* (find-files "." ".*\\.xml(-good)?")
262 (("http://www.oasis-open.org/docbook/xml/4.1.2/")
263 (string-append (assoc-ref inputs "docbook-xml")
264 "/xml/dtd/docbook/")))
265 #t))
266 (add-before 'build 'do-not-override-PERL5LIB
267 (lambda _
268 ;; Don't hard-code PERL5LIB to include just the build directory
269 ;; so that the build script finds modules from inputs.
270 (substitute* "Po4aBuilder.pm"
271 (("PERL5LIB=lib") ""))
272 (setenv "PERL5LIB" (string-append (getenv "PERL5LIB") ":lib"))))
273 (add-before 'check 'disable-failing-tests
274 (lambda _
275 ;; FIXME: these tests require SGMLS.pm.
276 (delete-file "t/01-classes.t")
277
278 (delete-file "t/add.t")
279 (delete-file "t/core-porefs.t")
280 (delete-file "t/fmt-asciidoc.t")
281 (delete-file "t/fmt-sgml.t")
282
283 #t)))))
284 (native-inputs
285 `(("gettext" ,gettext-minimal)
286 ("perl-module-build" ,perl-module-build)
287 ("docbook-xsl" ,docbook-xsl)
288 ("libxml2" ,libxml2)
289 ("xsltproc" ,libxslt)
290
291 ;; For tests.
292 ("docbook-xml" ,docbook-xml-4.1.2)
293 ("perl-test-pod" ,perl-test-pod)
294 ("perl-yaml-tiny" ,perl-yaml-tiny)
295 ("texlive" ,texlive-tiny)))
296 (inputs
297 (list perl-pod-parser))
298 (home-page "https://po4a.org/")
299 (synopsis "Scripts to ease maintenance of translations")
300 (description
301 "The po4a (PO for anything) project goal is to ease translations (and
302 more interestingly, the maintenance of translations) using gettext tools on
303 areas where they were not expected like documentation.")
304 (license gpl2+)))