cl-libre-translate

2025-06-22

A Common Lisp client for the Libre Translate API for translating between human languages. See https://github.com/LibreTranslate/LibreTranslate to setup the Libre Translate service.

Upstream URL

github.com/jl2/cl-libre-translate

Author

Jeremiah LaRocco <jeremiah_larocco@fastmail.com>

License

ISC
README

1cl-libre-translate

1.1About

An easy to use Common Lisp binding for the Libre Translate service.

1.2Using

The easiest way to use this package is with the Docker configuration from Libre Translate.

Clone the Libre Translate repo and start the service using:

  ./run.sh --port 5001

Once the service has downloaded all of the language files, use the library to translate text:

    (ql:quickload :cl-libre-translate)
    (use-package :st-json)
    (let ((result (lt:translate "This is a test!" :source "en" :target "zt")))
      (getjso "translatedText" result))
有考驗了!

To see the supported languages:

  (ql:quickload :cl-libre-translate)
  (use-package :st-json)
  (lt:show-languages)
To load "cl-libre-translate":
  Load 1 ASDF system:
    cl-libre-translate
; Loading "cl-libre-translate"

Urdu (ur)
Ukranian (uk)
Turkish (tr)
Thai (th)
Tagalog (tl)
Swedish (sv)
Spanish (es)
Slovenian (sl)
Slovak (sk)
Russian (ru)
Romanian (ro)
Portuguese (pt)
Polish (pl)
Persian (fa)
Norwegian (nb)
Malay (ms)
Lithuanian (lt)
Latvian (lv)
Korean (ko)
Japanese (ja)
Italian (it)
Irish (ga)
Indonesian (id)
Hungarian (hu)
Hindi (hi)
Hebrew (he)
Greek (el)
German (de)
Galician (gl)
French (fr)
Finnish (fi)
Estonian (et)
Esperanto (eo)
Dutch (nl)
Danish (da)
Czech (cs)
Chinese (traditional) (zt)
Chinese (zh)
Catalan (ca)
Bulgarian (bg)
Bengali (bn)
Basque (eu)
Azerbaijani (az)
Arabic (ar)
Albanian (sq)
English (en)

Parameters (and a config file) can be used to configure the Libre Translate server and API keys.

  (ql:quickload :cl-libre-translate)
  (use-package :st-json)
  (let* ((lt:*libre-translate-url* "https://libretranslate.com")
         (lt:*api-key* "Some API key")
         (result (lt:translate "This is a test!" :source "en" :target "es")))
    (getjso "translatedText" result))
¡Esto es una prueba!

1.3Config file

Config settings can also be read from a JSON file pointed to by the lt:*config-file* parameter. Thedefault location is in the package directory. The default configuration is shown below.

1.3.1Example Config

  {
      "api-key": "",
      "url": "http://localhost:5001",
      "default-target": "es",
      "default-source": "auto"
  }

1.4API Keys Untested

So far I've only used this package against a local Docker service, without API keys. I have little usefor the API keys right now, so I don't plan to test them. If they are not working, please let me know,and I'll try to fix them. A PR fixing the problem would also be welcome.

1.5License

ISC

Copyright (c) 2024 Jeremiah LaRocco <jeremiah_larocco@fastmail.com>

Dependencies (6)

  • alexandria
  • dexador
  • fiveam
  • st-json
  • trivial-clipboard
  • uiop

Dependents (0)

    • GitHub
    • Quicklisp