[go: up one dir, main page]

Skip to content

Common Lisp package for human language translation using Libre Translate.

License

Notifications You must be signed in to change notification settings

jl2/cl-libre-translate

Repository files navigation

cl-libre-translate

About

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

Using

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)

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))

Config file

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

Example Config

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

API Keys Untested

So far I’ve only used this package against a local Docker service, without API keys. I have little use for 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.

License

ISC

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

About

Common Lisp package for human language translation using Libre Translate.

Topics

Resources

License

Stars

Watchers

Forks