gettext.scm 13 KB

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