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>
15 ;;; This file is part of GNU Guix.
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.
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.
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/>.
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))
52 (define-public gettext-minimal
54 (name "gettext-minimal")
58 (uri (string-append "mirror://gnu/gettext/gettext-"
62 "04kbg1sx0ncfrsbr85ggjslqkzzb243fcw9nyh3rrv1a22ihszf7"))))
63 (build-system gnu-build-system)
65 "doc")) ;9 MiB of HTML
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'.
74 `(#:configure-flags '("--with-included-libunistring=no"
75 "--with-included-libxml=no")
77 (modify-phases %standard-phases
78 (add-before 'patch-source-shebangs 'patch-fixed-paths
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")
85 (substitute* '("gettext-tools/src/project-id"
86 "gettext-tools/projects/KDE/trigger"
87 "gettext-tools/projects/GNOME/trigger")
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))
98 (find-files "gettext-tools/tests"
99 "^(lang-sh|msg(exec|filter)-[0-9])")
100 (("#![[:blank:]]/bin/sh")
101 (format #f "#!~a" bash)))
103 (substitute* (cons "gettext-tools/src/msginit.c"
104 (find-files "gettext-tools/gnulib-tests"
109 (substitute* "gettext-tools/src/project-id"
115 ;; When tests fail, we want to know the details.
116 #:make-flags '("VERBOSE=yes"
118 ;; Linking to libgettextlib.so makes test-raise fail
119 '("XFAIL_TESTS=test-raise")
121 (home-page "https://www.gnu.org/software/gettext/")
123 "Tools and documentation for translation (used to build other packages)")
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+
133 ;; Use that name to avoid clashes with Guile's 'gettext' procedure.
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
144 (substitute-keyword-arguments (package-arguments gettext-minimal)
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")
155 (native-inputs `(("emacs" ,emacs-minimal))) ; for Emacs tools
156 (synopsis "Tools and documentation for translation")))
158 (define-public libtextstyle
160 (name "libtextstyle")
163 (inherit (package-source gnu-gettext))
164 (uri (string-append "mirror://gnu/gettext/gettext-"
168 "04kbg1sx0ncfrsbr85ggjslqkzzb243fcw9nyh3rrv1a22ihszf7"))))
169 (build-system gnu-build-system)
171 '(#:configure-flags '("--disable-static")
172 #:phases (modify-phases %standard-phases
173 (add-after 'unpack 'chdir
175 (chdir "libtextstyle")
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")
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.")
196 (uri (pypi-uri "mdpo" version))
198 (base32 "0kgbm0af7jwpfspa2xxiy9nc2l1r2s1rhbhz4r229zcqv49ak6sq"))))
199 (build-system python-build-system)
201 (list python-bump2version
203 python-flake8-implicit-str-concat
210 python-sphinx-argparse
211 python-sphinx-rtd-theme
215 (list python-polib python-pymd4c))
216 (home-page "https://github.com/mondeja/mdpo")
217 (synopsis "Markdown file translation utilities using pofiles")
219 "The mdpo utility creates pofiles, the format stabilished by GNU Gettext,
220 from Markdown files.")
229 (uri (string-append "https://github.com/mquinson/po4a/releases/download/v"
230 version "/po4a-" version ".tar.gz"))
233 "1kmlfpdl1i1wrcdn0k1frh44fq10sfwswi3azvibli2lakpf66z2"))))
234 (build-system perl-build-system)
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)
249 `("PERL5LIB" ":" prefix (,path))))
250 (find-files bin "\\.*$"))
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")
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/")))
266 (add-before 'build 'do-not-override-PERL5LIB
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
275 ;; FIXME: these tests require SGMLS.pm.
276 (delete-file "t/01-classes.t")
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")
285 `(("gettext" ,gettext-minimal)
286 ("perl-module-build" ,perl-module-build)
287 ("docbook-xsl" ,docbook-xsl)
289 ("xsltproc" ,libxslt)
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)))
297 (list perl-pod-parser))
298 (home-page "https://po4a.org/")
299 (synopsis "Scripts to ease maintenance of translations")
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.")