bug-guix
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#32026: LibreOffice locales


From: Ludovic Courtès
Subject: bug#32026: LibreOffice locales
Date: Wed, 22 Feb 2023 10:19:21 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux)

Hi!

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

> Ludovic Courtès <ludo@gnu.org> writes:

[...]

>> (A couple of years ago I started working on that for the LibreOffice
>> package.  I got quite far but didn’t complete it.  I can dig that from
>> my stashes if there’s interest in giving a hand.)
>
> I'd be interested to pick it up, yes!  Perhaps not in the coming 2
> weeks, which will be very busy for me, but afterward.

Here’s the WIP patch and associated LibreOffice patch (which didn’t
quite work for some reason: LO wouldn’t look for locales where I wanted
it to.)

Ludo’.

Unstaged
modified   gnu/packages/libreoffice.scm
@@ -6,7 +6,7 @@
 ;;; Copyright © 2017 Thomas Danckaert <post@thomasdanckaert.be>
 ;;; Copyright © 2017, 2018 Tobias Geerinckx-Rice <me@tobias.gr>
 ;;; Copyright © 2017 Andy Wingo <wingo@igalia.com>
-;;; Copyright © 2017, 2018 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2017, 2018, 2019 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2017 Rutger Helling <rhelling@mykolab.com>
 ;;; Copyright © 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
@@ -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"))

Define a new environment variable to determine the directory where
message catalogs ('.mo' files) are to be be looked up.

LibreOffice already has environment variables such as 'BRAND_BASE_DIR'
and 'BRAND_SHARE_RESOURCE_SUBDIR' but these are not helpful in this
case.

Patch by Ludovic Courtès <ludo@gnu.org>.

--- libreoffice-6.1.5.2/unotools/source/i18n/resmgr.cxx 2019-03-10 
16:22:21.352963608 +0100
+++ libreoffice-6.1.5.2/unotools/source/i18n/resmgr.cxx 2019-03-10 
16:30:20.090848346 +0100
@@ -144,6 +144,11 @@ namespace Translate
         rtl::Bootstrap::expandMacros(uri);
         OUString path;
         osl::File::getSystemPathFromFileURL(uri, path);
+
+        const char *cLocaleDir = ::getenv("LO_LOCALE_DIRECTORY");
+        if (cLocaleDir != NULL)
+            path = OUString::createFromAscii(cLocaleDir);
+
         OString sPath(OUStringToOString(path, osl_getThreadTextEncoding()));
         gen.add_messages_path(sPath.getStr());
 #if defined UNX && !defined MACOSX && !defined IOS && !defined ANDROID


reply via email to

[Prev in Thread] Current Thread [Next in Thread]