gnu: facter: Update to 4.0.34.
[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 Marius Bakke <mbakke@fastmail.com>
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 ;;;
13 ;;; This file is part of GNU Guix.
14 ;;;
15 ;;; GNU Guix is free software; you can redistribute it and/or modify it
16 ;;; under the terms of the GNU General Public License as published by
17 ;;; the Free Software Foundation; either version 3 of the License, or (at
18 ;;; your option) any later version.
19 ;;;
20 ;;; GNU Guix is distributed in the hope that it will be useful, but
21 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
22 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 ;;; GNU General Public License for more details.
24 ;;;
25 ;;; You should have received a copy of the GNU General Public License
26 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
27
28 (define-module (gnu packages gettext)
29 #:use-module ((guix licenses) #:select (gpl2+ gpl3+))
30 #:use-module (gnu packages)
31 #:use-module (guix packages)
32 #:use-module (guix download)
33 #:use-module (guix build-system gnu)
34 #:use-module (guix build-system perl)
35 #:use-module (gnu packages docbook)
36 #:use-module (gnu packages emacs)
37 #:use-module (gnu packages libunistring)
38 #:use-module (gnu packages ncurses)
39 #:use-module (gnu packages perl)
40 #:use-module (gnu packages tex)
41 #:use-module (gnu packages xml)
42 #:use-module (guix utils))
43
44 (define-public gettext-minimal
45 (package
46 (name "gettext-minimal")
47 (version "0.20.1")
48 (source (origin
49 (method url-fetch)
50 (uri (string-append "mirror://gnu/gettext/gettext-"
51 version ".tar.gz"))
52 (sha256
53 (base32
54 "0p3zwkk27wm2m2ccfqm57nj7vqkmfpn7ja1nf65zmhz8qqs5chb6"))))
55 (build-system gnu-build-system)
56 (outputs '("out"
57 "doc")) ;9 MiB of HTML
58 (inputs
59 `(("libunistring" ,libunistring)
60 ("libxml2" ,libxml2)
61
62 ;; TODO: ncurses is only needed for the 'libtextstyle' library.
63 ;; The next version of gettext can use a separate libtextstyle,
64 ;; but for now we include it here in 'gettext-minimal'.
65 ("ncurses" ,ncurses)))
66 (arguments
67 `(#:configure-flags '("--with-included-libunistring=no"
68 "--with-included-libxml=no")
69 #:phases
70 (modify-phases %standard-phases
71 (add-before 'patch-source-shebangs 'patch-fixed-paths
72 (lambda _
73 (substitute* '("gettext-tools/config.h.in"
74 "gettext-tools/gnulib-tests/init.sh"
75 "gettext-tools/tests/init.sh"
76 "gettext-tools/system-tests/run-test")
77 (("/bin/sh") "sh"))
78 (substitute* '("gettext-tools/src/project-id"
79 "gettext-tools/projects/KDE/trigger"
80 "gettext-tools/projects/GNOME/trigger")
81 (("/bin/pwd") "pwd"))
82 #t))
83 (add-before 'check 'patch-tests
84 (lambda* (#:key inputs #:allow-other-keys)
85 (let* ((bash (which "sh")))
86 ;; Some of the files we're patching are
87 ;; ISO-8859-1-encoded, so choose it as the default
88 ;; encoding so the byte encoding is preserved.
89 (with-fluids ((%default-port-encoding #f))
90 (substitute*
91 (find-files "gettext-tools/tests"
92 "^(lang-sh|msg(exec|filter)-[0-9])")
93 (("#![[:blank:]]/bin/sh")
94 (format #f "#!~a" bash)))
95
96 (substitute* (cons "gettext-tools/src/msginit.c"
97 (find-files "gettext-tools/gnulib-tests"
98 "posix_spawn"))
99 (("/bin/sh")
100 bash))
101
102 (substitute* "gettext-tools/src/project-id"
103 (("/bin/pwd")
104 "pwd"))
105
106 #t)))))
107
108 ;; When tests fail, we want to know the details.
109 #:make-flags '("VERBOSE=yes")))
110 (home-page "https://www.gnu.org/software/gettext/")
111 (synopsis
112 "Tools and documentation for translation (used to build other packages)")
113 (description
114 "GNU Gettext is a package providing a framework for translating the
115 textual output of programs into multiple languages. It provides translators
116 with the means to create message catalogs, and a runtime library to load
117 translated messages from the catalogs. Nearly all GNU packages use Gettext.")
118 (properties `((upstream-name . "gettext")
119 (cpe-name . "gettext")))
120 (license gpl3+))) ;some files are under GPLv2+
121
122 ;; Use that name to avoid clashes with Guile's 'gettext' procedure.
123 ;;
124 ;; We used to resort to #:renamer on the user side, but that prevented
125 ;; circular dependencies involving (gnu packages gettext). This is because
126 ;; 'resolve-interface' (as of Guile 2.0.9) iterates eagerly over the used
127 ;; module when there's a #:renamer, and that module may be empty at that point
128 ;; in case or circular dependencies.
129 (define-public gnu-gettext
130 (package
131 (inherit gettext-minimal)
132 (name "gettext")
133 (arguments
134 (substitute-keyword-arguments (package-arguments gettext-minimal)
135 ((#:phases phases)
136 `(modify-phases ,phases
137 (add-after 'install 'add-emacs-autoloads
138 (lambda* (#:key outputs #:allow-other-keys)
139 ;; Make 'po-mode' and other things available by default.
140 (with-directory-excursion
141 (string-append (assoc-ref outputs "out")
142 "/share/emacs/site-lisp")
143 (symlink "start-po.el" "gettext-autoloads.el")
144 #t)))))))
145 (native-inputs `(("emacs" ,emacs-minimal))) ; for Emacs tools
146 (synopsis "Tools and documentation for translation")))
147
148 (define-public libtextstyle
149 (package
150 (name "libtextstyle")
151 (version "0.21")
152 (source (origin
153 (inherit (package-source gnu-gettext))
154 (uri (string-append "mirror://gnu/gettext/gettext-"
155 version ".tar.gz"))
156 (sha256
157 (base32
158 "04kbg1sx0ncfrsbr85ggjslqkzzb243fcw9nyh3rrv1a22ihszf7"))))
159 (build-system gnu-build-system)
160 (arguments
161 '(#:configure-flags '("--disable-static")
162 #:phases (modify-phases %standard-phases
163 (add-after 'unpack 'chdir
164 (lambda _
165 (chdir "libtextstyle")
166 #t)))))
167 ;; libtextstyle bundles libxml2, glib (a small subset thereof), and
168 ;; libcroco, but it purposefully prevents users from using an external
169 ;; copy, to reduce the startup time of programs using libtextstyle.
170 (home-page "https://www.gnu.org/software/gettext/")
171 (synopsis "Text styling library")
172 (description
173 "GNU libtextstyle is a C library that provides an easy way to add styling
174 to programs that produce output to a console or terminal emulator window. It
175 allows applications to emit text annotated with styling information, such as
176 color, font attributes (weight, posture), or underlining.")
177 (license gpl3+)))
178
179 (define-public po4a
180 (package
181 (name "po4a")
182 (version "0.57")
183 (source (origin
184 (method url-fetch)
185 (uri (string-append "https://github.com/mquinson/po4a/releases/download/v"
186 version "/po4a-" version ".tar.gz"))
187 (sha256
188 (base32
189 "15yd27krlpdvjhcnwys6i5k1ww62ifq2yx8k1zxyxiwy84myqmdv"))))
190 (build-system perl-build-system)
191 (arguments
192 `(#:phases
193 (modify-phases %standard-phases
194 (add-after 'install 'wrap-programs
195 (lambda* (#:key outputs #:allow-other-keys)
196 ;; Make sure all executables in "bin" find the Perl modules
197 ;; provided by this package at runtime.
198 (let* ((out (assoc-ref outputs "out"))
199 (bin (string-append out "/bin/"))
200 (path (string-append out "/lib/perl5/site_perl")))
201 (for-each (lambda (file)
202 (wrap-program file
203 `("PERL5LIB" ":" prefix (,path))))
204 (find-files bin "\\.*$"))
205 #t)))
206 (add-before 'reset-gzip-timestamps 'make-compressed-files-writable
207 (lambda* (#:key outputs #:allow-other-keys)
208 (for-each make-file-writable
209 (find-files (string-append (assoc-ref outputs "out")
210 "/share/man")
211 ".*\\.gz$"))
212 #t))
213 (add-after 'unpack 'patch-docbook-xml
214 (lambda* (#:key inputs #:allow-other-keys)
215 (substitute* (find-files "." ".*\\.xml(-good)?")
216 (("http://www.oasis-open.org/docbook/xml/4.1.2/")
217 (string-append (assoc-ref inputs "docbook-xml")
218 "/xml/dtd/docbook/")))
219 #t))
220 (add-before 'check 'disable-failing-tests
221 (lambda _
222 ;; FIXME: ‘Files ../t-03-asciidoc/Titles.po and Titles.po differ’.
223 (delete-file "t/03-asciidoc.t")
224
225 ;; FIXME: these tests require SGMLS.pm.
226 (delete-file "t/01-classes.t")
227 (delete-file "t/16-sgml.t")
228
229 #t)))))
230 (native-inputs
231 `(("gettext" ,gettext-minimal)
232 ("perl-module-build" ,perl-module-build)
233 ("docbook-xsl" ,docbook-xsl)
234 ("libxml2" ,libxml2)
235 ("xsltproc" ,libxslt)
236
237 ;; For tests.
238 ("docbook-xml" ,docbook-xml-4.1.2)
239 ("perl-yaml-tiny" ,perl-yaml-tiny)
240 ("texlive" ,texlive-tiny)))
241 (home-page "https://po4a.org/")
242 (synopsis "Scripts to ease maintenance of translations")
243 (description
244 "The po4a (PO for anything) project goal is to ease translations (and
245 more interestingly, the maintenance of translations) using gettext tools on
246 areas where they were not expected like documentation.")
247 (license gpl2+)))