From 0aa4bcac7fba5c35391d47c5a27bd47d977b7835 Mon Sep 17 00:00:00 2001 From: Piero Toffanin Date: Wed, 15 Nov 2023 13:57:54 -0500 Subject: [PATCH] Add FAQ --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 7f56c9a..551dabd 100644 --- a/README.md +++ b/README.md @@ -606,6 +606,30 @@ Add this to an existing NGINX config or save it as `libretranslate` in the `/etc +### Can I do batch translations? + +Yes, pass an array of strings instead of a string to the `q` field: + +```javascript +const res = await fetch("https://libretranslate.com/translate", { + method: "POST", + body: JSON.stringify({ + q: ["Hello", "world"], + source: "en", + target: "es" + }), + headers: { "Content-Type": "application/json" } +}); + +console.log(await res.json()); +// { +// "translatedText": [ +// "Hola", +// "mundo" +// ] +// } +``` + ## Credits This work is largely possible thanks to [Argos Translate](https://github.com/argosopentech/argos-translate), which powers the translation engine.