1
0
mirror of https://github.com/LibreTranslate/LibreTranslate.git synced 2024-12-18 08:27:03 +02:00
This commit is contained in:
Piero Toffanin 2023-11-15 13:57:54 -05:00
parent b0a84f30f4
commit 0aa4bcac7f

View File

@ -606,6 +606,30 @@ Add this to an existing NGINX config or save it as `libretranslate` in the `/etc
</details>
### 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.