gnu: emacs-consult: Fix grammar.
[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 ;;; 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.20.1")
56 (source (origin
57 (method url-fetch)
58 (uri (string-append "mirror://gnu/gettext/gettext-"
59 version ".tar.gz"))
60 (sha256
61 (base32
62 "0p3zwkk27wm2m2ccfqm57nj7vqkmfpn7ja1nf65zmhz8qqs5chb6"))))
63 (build-system gnu-build-system)
64 (outputs '("out"
65 "doc")) ;9 MiB of HTML
66 (inputs
67 `(("libunistring" ,libunistring)
68 ("libxml2" ,libxml2)
69
70 ;; TODO: ncurses is only needed for the 'libtextstyle' library.
71 ;; The next version of gettext can use a separate libtextstyle,
72 ;; but for now we include it here in 'gettext-minimal'.
73 ("ncurses" ,ncurses)))
74 (arguments
75 `(#:configure-flags '("--with-included-libunistring=no"
76 "--with-included-libxml=no")
77 #:phases
78 (modify-phases %standard-phases
79 (add-before 'patch-source-shebangs 'patch-fixed-paths
80 (lambda _
81 (substitute* '("gettext-tools/config.h.in"
82 "gettext-tools/gnulib-tests/init.sh"
83 "gettext-tools/tests/init.sh"
84 "gettext-tools/system-tests/run-test")
85 (("/bin/sh") "sh"))
86 (substitute* '("gettext-tools/src/project-id"
87 "gettext-tools/projects/KDE/trigger"
88 "gettext-tools/projects/GNOME/trigger")
89 (("/bin/pwd") "pwd"))
90 #t))
91 (add-before 'check 'patch-tests
92 (lambda* (#:key inputs #:allow-other-keys)
93 (let* ((bash (which "sh")))
94 ;; Some of the files we're patching are
95 ;; ISO-8859-1-encoded, so choose it as the default
96 ;; encoding so the byte encoding is preserved.
97 (with-fluids ((%default-port-encoding #f))
98 (substitute*
99 (find-files "gettext-tools/tests"
100 "^(lang-sh|msg(exec|filter)-[0-9])")
101 (("#![[:blank:]]/bin/sh")
102 (format #f "#!~a" bash)))
103
104 (substitute* (cons "gettext-tools/src/msginit.c"
105 (find-files "gettext-tools/gnulib-tests"
106 "posix_spawn"))
107 (("/bin/sh")
108 bash))
109
110 (substitute* "gettext-tools/src/project-id"
111 (("/bin/pwd")
112 "pwd"))
113
114 #t)))))
115
116 ;; When tests fail, we want to know the details.
117 #:make-flags '("VERBOSE=yes"
118 ,@(if (hurd-target?)
119 ;; Linking to libgettextlib.so makes test-raise fail
120 '("XFAIL_TESTS=test-raise")
121 '()))))
122 (home-page "https://www.gnu.org/software/gettext/")
123 (synopsis
124 "Tools and documentation for translation (used to build other packages)")
125 (description
126 "GNU Gettext is a package providing a framework for translating the
127 textual output of programs into multiple languages. It provides translators
128 with the means to create message catalogs, and a runtime library to load
129 translated messages from the catalogs. Nearly all GNU packages use Gettext.")
130 (properties `((upstream-name . "gettext")
131 (cpe-name . "gettext")))
132 (license gpl3+))) ;some files are under GPLv2+
133
134 ;; Use that name to avoid clashes with Guile's 'gettext' procedure.
135 ;;
136 ;; We used to resort to #:renamer on the user side, but that prevented
137 ;; circular dependencies involving (gnu packages gettext). This is because
138 ;; 'resolve-interface' (as of Guile 2.0.9) iterates eagerly over the used
139 ;; module when there's a #:renamer, and that module may be empty at that point
140 ;; in case or circular dependencies.
141 (define-public gnu-gettext
142 (package/inherit gettext-minimal
143 (name "gettext")
144 (arguments
145 (substitute-keyword-arguments (package-arguments gettext-minimal)
146 ((#:phases phases)
147 `(modify-phases ,phases
148 (add-after 'install 'add-emacs-autoloads
149 (lambda* (#:key outputs #:allow-other-keys)
150 ;; Make 'po-mode' and other things available by default.
151 (with-directory-excursion
152 (string-append (assoc-ref outputs "out")
153 "/share/emacs/site-lisp")
154 (symlink "start-po.el" "gettext-autoloads.el")
155 #t)))))))
156 (native-inputs `(("emacs" ,emacs-minimal))) ; for Emacs tools
157 (synopsis "Tools and documentation for translation")))
158
159 (define-public libtextstyle
160 (package
161 (name "libtextstyle")
162 (version "0.21")
163 (source (origin
164 (inherit (package-source gnu-gettext))
165 (uri (string-append "mirror://gnu/gettext/gettext-"
166 version ".tar.gz"))
167 (sha256
168 (base32
169 "04kbg1sx0ncfrsbr85ggjslqkzzb243fcw9nyh3rrv1a22ihszf7"))))
170 (build-system gnu-build-system)
171 (arguments
172 '(#:configure-flags '("--disable-static")
173 #:phases (modify-phases %standard-phases
174 (add-after 'unpack 'chdir
175 (lambda _
176 (chdir "libtextstyle")
177 #t)))))
178 ;; libtextstyle bundles libxml2, glib (a small subset thereof), and
179 ;; libcroco, but it purposefully prevents users from using an external
180 ;; copy, to reduce the startup time of programs using libtextstyle.
181 (home-page "https://www.gnu.org/software/gettext/")
182 (synopsis "Text styling library")
183 (description
184 "GNU libtextstyle is a C library that provides an easy way to add styling
185 to programs that produce output to a console or terminal emulator window. It
186 allows applications to emit text annotated with styling information, such as
187 color, font attributes (weight, posture), or underlining.")
188 (license gpl3+)))
189
190 (define-public mdpo
191 (package
192 (name "mdpo")
193 (version "0.3.6")
194 (source
195 (origin
196 (method url-fetch)
197 (uri (pypi-uri "mdpo" version))
198 (sha256
199 (base32 "0kgbm0af7jwpfspa2xxiy9nc2l1r2s1rhbhz4r229zcqv49ak6sq"))))
200 (build-system python-build-system)
201 (native-inputs
202 `(("python-bump2version" ,python-bump2version)
203 ("python-flake8" ,python-flake8)
204 ("python-flake8-implicit-str-concat" ,python-flake8-implicit-str-concat)
205 ("python-flake8-print" ,python-flake8-print)
206 ("python-isort" ,python-isort)
207 ("python-pre-commit" ,python-pre-commit)
208 ("python-pytest" ,python-pytest)
209 ("python-pytest-cov" ,python-pytest-cov)
210 ("python-sphinx" ,python-sphinx)
211 ("python-sphinx-argparse" ,python-sphinx-argparse)
212 ("python-sphinx-rtd-theme" ,python-sphinx-rtd-theme)
213 ("python-twine" ,python-twine)
214 ("python-yamllint" ,python-yamllint)))
215 (propagated-inputs
216 `(("python-polib" ,python-polib)
217 ("python-pymd4c" ,python-pymd4c)))
218 (home-page "https://github.com/mondeja/mdpo")
219 (synopsis "Markdown file translation utilities using pofiles")
220 (description
221 "The mdpo utility creates pofiles, the format stabilished by GNU Gettext,
222 from Markdown files.")
223 (license bsd-3)))
224
225 (define-public po4a
226 (package
227 (name "po4a")
228 (version "0.61")
229 (source (origin
230 (method url-fetch)
231 (uri (string-append "https://github.com/mquinson/po4a/releases/download/v"
232 version "/po4a-" version ".tar.gz"))
233 (sha256
234 (base32
235 "1nw61dj7ymrsjps79vvfdzp549drwd51kyj598937zvyafq4r5b2"))))
236 (build-system perl-build-system)
237 (arguments
238 `(#:phases
239 (modify-phases %standard-phases
240 (add-after 'install 'wrap-programs
241 (lambda* (#:key outputs #:allow-other-keys)
242 ;; Make sure all executables in "bin" find the Perl modules
243 ;; provided by this package at runtime.
244 (let* ((out (assoc-ref outputs "out"))
245 (bin (string-append out "/bin/"))
246 (path (string-append out "/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 'check 'disable-failing-tests
267 (lambda _
268 ;; FIXME: these tests require SGMLS.pm.
269 (delete-file "t/01-classes.t")
270
271 (delete-file "t/add.t")
272 (delete-file "t/core-porefs.t")
273 (delete-file "t/fmt-asciidoc.t")
274 (delete-file "t/fmt-sgml.t")
275
276 #t)))))
277 (native-inputs
278 `(("gettext" ,gettext-minimal)
279 ("perl-module-build" ,perl-module-build)
280 ("docbook-xsl" ,docbook-xsl)
281 ("libxml2" ,libxml2)
282 ("xsltproc" ,libxslt)
283
284 ;; For tests.
285 ("docbook-xml" ,docbook-xml-4.1.2)
286 ("perl-test-pod" ,perl-test-pod)
287 ("perl-yaml-tiny" ,perl-yaml-tiny)
288 ("texlive" ,texlive-tiny)))
289 (home-page "https://po4a.org/")
290 (synopsis "Scripts to ease maintenance of translations")
291 (description
292 "The po4a (PO for anything) project goal is to ease translations (and
293 more interestingly, the maintenance of translations) using gettext tools on
294 areas where they were not expected like documentation.")
295 (license gpl2+)))