mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-08-20 05:10:13 +02:00
Add auto-detect example
This commit is contained in:
parent
a13a714b89
commit
8962de8755
28
README.md
28
README.md
@ -14,7 +14,7 @@ Free and Open Source Machine Translation API, entirely self-hosted. Unlike other
|
|||||||
## API Examples
|
## API Examples
|
||||||
|
|
||||||
|
|
||||||
### Plain Text
|
### Simple
|
||||||
|
|
||||||
Request:
|
Request:
|
||||||
|
|
||||||
@ -40,6 +40,32 @@ Response:
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Auto Detect Language
|
||||||
|
|
||||||
|
Request:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const res = await fetch("https://libretranslate.com/translate", {
|
||||||
|
method: "POST",
|
||||||
|
body: JSON.stringify({
|
||||||
|
q: "Ciao!",
|
||||||
|
source: "auto",
|
||||||
|
target: "en"
|
||||||
|
}),
|
||||||
|
headers: { "Content-Type": "application/json" }
|
||||||
|
});
|
||||||
|
|
||||||
|
console.log(await res.json());
|
||||||
|
```
|
||||||
|
|
||||||
|
Response:
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
{
|
||||||
|
"translatedText": "Bye!"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### HTML (beta)
|
### HTML (beta)
|
||||||
|
|
||||||
Request:
|
Request:
|
||||||
|
Loading…
Reference in New Issue
Block a user