Subject: [PATCH 1/2] gnu: dict: Add symbols to help users configure FreeDict with dicod.

From: Runciter <[email-masked]>
Date: Tue, 24 Dec 2024 13:00:45 +0000

* gnu/services/dict.scm: (%dictorg-handler): New variable;
(freedict-dictorg-database): new procedure;
(%freedict-dictorg-databases): new variable.

Signed-off-by: Runciter <[email-masked]>
---
 gnu/services/dict.scm | 107 +++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 106 insertions(+), 1 deletion(-)

diff --git a/gnu/services/dict.scm b/gnu/services/dict.scm
index a4e25f5302..39fb38c9c3 100644
--- a/gnu/services/dict.scm
+++ b/gnu/services/dict.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2016 Sou Bunnbu <[email-masked]>
 ;;; Copyright © 2016, 2017, 2018, 2020, 2022, 2023 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2017 Huang Ying <[email-masked]>
+;;; Copyright © 2024 Runciter <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -40,7 +41,10 @@ (define-module (gnu services dict)
             dicod-configuration
             dicod-handler
             dicod-database
-            %dicod-database:gcide))
+            %dicod-database:gcide
+            %dictorg-handler
+            freedict-dictorg-database
+            %freedict-dictorg-databases))
 
 
 ;;;
@@ -94,6 +98,107 @@ (define %dicod-database:gcide
    (options (list #~(string-append "dbdir=" #$gcide "/share/gcide")
                   #~(string-append "idxdir=" #$%dicod-gcide-index)))))
 
+(define %dictorg-handler
+  (dicod-handler (name "dictorg")
+                 (module "dictorg")
+                 (options (list #~(string-append "dbdir=/")))))
+
+(define (freedict-dictorg-database dict-name)
+  "Return a record of type @code{<dicod-database>} that configures a
+database for the freedict multilingual dictionary named by the string
+DICT-NAME."
+  (dicod-database (name (string-append "freedict-"
+                                       dict-name))
+                  (complex? #t)
+                  (handler "dictorg")
+                  (options (list #~(string-append "database="
+                                                  #$freedict-dictionaries
+                                                  "/share/dictd/"
+                                                  #$dict-name)))))
+
+(define %freedict-dictorg-databases
+  (map freedict-dictorg-database (list "afr-deu"
+                                       "afr-eng"
+                                       "ara-eng"
+                                       "bre-fra"
+                                       "ces-eng"
+                                       "ckb-kmr"
+                                       "cym-eng"
+                                       "dan-eng"
+                                       "deu-ita"
+                                       "deu-kur"
+                                       "deu-nld"
+                                       "deu-por"
+                                       "deu-tur"
+                                       "eng-afr"
+                                       "eng-ara"
+                                       "eng-ces"
+                                       "eng-cym"
+                                       "eng-dan"
+                                       "eng-ell"
+                                       "eng-fra"
+                                       "eng-gle"
+                                       "eng-hin"
+                                       "eng-hrv"
+                                       "eng-hun"
+                                       "eng-ita"
+                                       "eng-lat"
+                                       "eng-lit"
+                                       "eng-nld"
+                                       "eng-pol"
+                                       "eng-por"
+                                       "eng-rom"
+                                       "eng-rus"
+                                       "eng-spa"
+                                       "eng-srp"
+                                       "eng-swh"
+                                       "eng-tur"
+                                       "fra-bre"
+                                       "fra-eng"
+                                       "fra-nld"
+                                       "gla-deu"
+                                       "gle-eng"
+                                       "gle-pol"
+                                       "hrv-eng"
+                                       "hun-eng"
+                                       "isl-eng"
+                                       "ita-deu"
+                                       "ita-eng"
+                                       "jpn-deu"
+                                       "jpn-eng"
+                                       "jpn-fra"
+                                       "jpn-rus"
+                                       "kha-deu"
+                                       "kha-eng"
+                                       "kur-deu"
+                                       "kur-eng"
+                                       "kur-tur"
+                                       "lat-deu"
+                                       "lat-eng"
+                                       "lit-eng"
+                                       "mkd-bul"
+                                       "nld-deu"
+                                       "nld-eng"
+                                       "nld-fra"
+                                       "nno-nob"
+                                       "oci-cat"
+                                       "pol-gle"
+                                       "por-deu"
+                                       "por-eng"
+                                       "san-deu"
+                                       "slk-eng"
+                                       "slv-eng"
+                                       "spa-ast"
+                                       "spa-eng"
+                                       "spa-por"
+                                       "srp-eng"
+                                       "swe-eng"
+                                       "swh-eng"
+                                       "swh-pol"
+                                       "tur-deu"
+                                       "tur-eng"
+                                       "wol-fra")))
+
 (define %dicod-accounts
   (list (user-group
          (name "dicod")
-- 
2.46.0