Unstaged modified gnu/packages/libreoffice.scm @@ -6,7 +6,7 @@ ;;; Copyright © 2017 Thomas Danckaert ;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice ;;; Copyright © 2017 Andy Wingo -;;; Copyright © 2017, 2018 Ludovic Courtès +;;; Copyright © 2017, 2018, 2019 Ludovic Courtès ;;; Copyright © 2017, 2018, 2019 Marius Bakke ;;; Copyright © 2017 Rutger Helling ;;; Copyright © 2018, 2019 Ricardo Wurmus @@ -53,6 +53,7 @@ (define-module (gnu packages libreoffice) #:use-module (gnu packages documentation) #:use-module (gnu packages flex) #:use-module (gnu packages fontutils) + #:use-module (gnu packages gettext) #:use-module (gnu packages ghostscript) #:use-module (gnu packages gl) #:use-module (gnu packages glib) @@ -969,7 +970,8 @@ (define-public libreoffice "0apbmammmp4pk473xiv5vk50r4c5gjvqzf9jkficksvz58q6114f")))) (search-patches "libreoffice-boost.patch" "libreoffice-icu.patch" - "libreoffice-glm.patch"))) + "libreoffice-glm.patch" + "libreoffice-locale-directory.patch"))) (modules '((guix build utils))) (snippet '(begin @@ -1164,6 +1166,16 @@ (define (install-appdata app) "--disable-pdfium" "--disable-gtk" ; disable use of GTK+ 2 "--without-doxygen"))) + + (native-search-paths + ;; This Guix-specific environment variable tells LibreOffice where to + ;; find locale data as provided by the 'libreoffice-translation-*' + ;; packages. + (list (search-path-specification + (variable "LO_LOCALE_DIRECTORY") + (separator #f) + (files '("share/libreoffice/locale"))))) + (home-page "https://www.libreoffice.org/") (synopsis "Office suite") (description "LibreOffice is a comprehensive office suite. It contains @@ -1172,3 +1184,84 @@ (define (install-appdata app) flowcharting application; Base, a database and database frontend; Math for editing mathematics.") (license mpl2.0))) + +(define (libreoffice-translation language) + (package + (inherit libreoffice) + (name (string-append "libreoffice-translation-" language)) + (version (package-version libreoffice)) + (build-system gnu-build-system) + (arguments + (substitute-keyword-arguments (package-arguments libreoffice) + ((#:phases phases '%standard-phases) + `(modify-phases ,phases + (add-after 'unpack 'unpack-translations + (lambda* (#:key inputs #:allow-other-keys) + (let ((translations (assoc-ref inputs "translations"))) + (mkdir "src") + (symlink translations + (string-append "src/libreoffice-translations-" + ,version ".tar.xz")) + #t))) + (replace 'build + (lambda _ + (invoke "make" "build-l10n-only" + "-j" (number->string (parallel-job-count))))) + (replace 'install + (lambda* (#:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out")) + (locale (string-append out + ,(string-append + "/share/libreoffice/locale/" + language + "/LC_MESSAGES"))) + (registry (string-append out + "/lib/libreoffice/share/registry"))) + (for-each (lambda (mo) + (install-file mo locale)) + (find-files "." "\\.mo$")) + (for-each (lambda (xcd) + (install-file xcd registry)) + (find-files "." "^Langpack-.*\\.xcd$")) + (for-each (lambda (xcd) + (install-file xcd + (string-append registry "/res"))) + (find-files "." + ,(string-append language "\\.xcd$"))) + #t))) + (delete 'bin-and-desktop-install))) + ((#:configure-flags flags '()) + `(cons ,(string-append "--with-lang=" language) ,flags)) + ((#:tests? _ #f) + #f))) + (native-inputs + `(("gettext" ,gnu-gettext) + ("translations" ,(origin + (method url-fetch) + (uri (string-append + "https://download.documentfoundation.org/libreoffice/src/" + (version-prefix version 3) "/libreoffice-translations-" + version ".tar.xz")) + (sha256 + (base32 + "15fdni68b3kyl6115v0d24cl0dp1hdjhkx571w086lrpz0fk9mfi")))) + ,@(package-native-inputs libreoffice))) + (synopsis "Translation of the LibreOffice user interface"))) + +(define %libreoffice-translations + ;; List of available translations. Obtained by calling 'scandir' on the + ;; contents of 'translations/source' from the "libreoffice-translations" + ;; tarball. + '("ab" "af" "am" "an" "ar" "as" "ast" "az" "be" "bg" "bn" "bn-IN" "bo" "br" + "brx" "bs" "ca" "ca-valencia" "cs" "cy" "da" "de" "dgo" "dz" "el" "en-GB" + "en-ZA" "eo" "es" "et" "eu" "fa" "fi" "fr" "fy" "ga" "gd" "gl" "gu" "gug" + "he" "hi" "hr" "hsb" "hu" "id" "is" "it" "ja" "jv" "ka" "kab" "kk" "kl" + "km" "kmr-Latn" "kn" "ko" "kok" "ks" "ky" "lb" "lo" "lt" "lv" "mai" "mk" + "ml" "mn" "mni" "mr" "my" "nb" "ne" "nl" "nn" "nr" "nso" "oc" "om" "or" + "pa-IN" "pl" "pt" "pt-BR" "ro" "ru" "rw" "sah" "sa-IN" "sat" "sd" "si" + "sid" "sk" "sl" "sq" "sr" "sr-Latn" "ss" "st" "sv" "sw-TZ" "szl" "ta" "te" + "tg" "th" "ti" "tn" "tr" "ts" "tt" "ug" "uk" "ur" "uz" "ve" "vec" "vi" + "xh" "zh-CN" "zh-TW" "zu")) + +(define-public libreoffice-l10n-fr + (libreoffice-translation "fr"))