mirror of
https://github.com/LibreTranslate/LibreTranslate.git
synced 2024-11-21 23:41:01 +00:00
Add auto-detect example
This commit is contained in:
parent
a13a714b89
commit
8962de8755
1 changed files with 27 additions and 1 deletions
28
README.md
28
README.md
|
@ -14,7 +14,7 @@ Free and Open Source Machine Translation API, entirely self-hosted. Unlike other
|
|||
## API Examples
|
||||
|
||||
|
||||
### Plain Text
|
||||
### Simple
|
||||
|
||||
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)
|
||||
|
||||
Request:
|
||||
|
|
Loading…
Reference in a new issue