Compare commits

..
7 Commits
5 changed files with 46 additions and 10 deletions
+25 -7
View File
@@ -2,7 +2,7 @@
* @Author: Vincent Young
* @Date: 2022-10-18 07:32:29
* @LastEditors: Vincent Young
* @LastEditTime: 2023-03-03 02:30:52
* @LastEditTime: 2023-03-16 20:24:59
* @FilePath: /DeepLX/README.md
* @Telegram: https://t.me/missuo
*
@@ -26,15 +26,32 @@ Permanently free DeepL API written in Golang
### Response
```json
{
"alternatives": [
"Undisputed",
"Unquestionable",
"Unquestionably"
],
"code": 200,
"data": "Hello world",
"id": 8305092005
"data": "Undoubtedly",
"id": 8300079001
}
```
### Run with Docker
```bash
# ghcr.io
docker run -itd -p 1188:1188 ghcr.io/owo-network/deeplx:latest
# dockerhub
docker run -itd -p 1188:1188 missuo/deeplx:latest
```
### Run with Docker Compose
```bash
mkdir deeplx
cd deeplx
wget https://raw.githubusercontent.com/OwO-Network/DeepLX/main/docker-compose.yaml
docker-compose up -d
```
### Run on Linux Server
@@ -58,7 +75,6 @@ brew services restart owo-network/brew/deeplx
brew list --versions deeplx
```
#### Manual
1. Download the latest release of DeepL X.
```bash
@@ -91,17 +107,19 @@ systemctl enable deeplx
## Setup on [Bob App](https://bobtranslate.com/)
1. Install [bob-plugin-deeplx](https://github.com/missuo/bob-plugin-deeplx) on Bob.
2. Setup the API.
2. Setup the API. (If you use Brew to install locally you can skip this step)
![c5c19dd89df6fae1a256d](https://missuo.ru/file/c5c19dd89df6fae1a256d.png)
## Setup on [immersive-translate](https://github.com/immersive-translate/immersive-translate)
**It is not recommended, because the `immersive-translate` will send many requests in a short time, which will cause the `DeepL API` to block your IP.**
1. Install Latest [immersive-translate ](https://github.com/immersive-translate/immersive-translate/releases) on your browser.
2. Click on **Developer Settings** in the bottom left corner. **Enable Beta experimental features**.
3. Set the URL.
3. Set the URL. (If you are not deploying locally, you need to change 127.0.0.1 to the IP of your server)
![0779ecf8c7d7d1bee532b](https://missuo.ru/file/0779ecf8c7d7d1bee532b.png)
![6a48ba28621f2465028f0](https://missuo.ru/file/6a48ba28621f2465028f0.png)
## Backup the Docker Image of zu1k
```shell
+8
View File
@@ -0,0 +1,8 @@
version: '3'
services:
deeplx:
image: ghcr.io/owo-network/deeplx:latest
restart: always
ports:
- "1188:1188"
+1
View File
@@ -10,6 +10,7 @@ require (
)
require (
github.com/Jeffail/gabs/v2 v2.7.0 // indirect
github.com/gin-contrib/sse v0.1.0 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
+2
View File
@@ -1,3 +1,5 @@
github.com/Jeffail/gabs/v2 v2.7.0 h1:Y2edYaTcE8ZpRsR2AtmPu5xQdFDIthFG0jYhu5PY8kg=
github.com/Jeffail/gabs/v2 v2.7.0/go.mod h1:dp5ocw1FvBBQYssgHsG7I1WYsiLRtkUaB1FEtSwvNUw=
github.com/abadojack/whatlanggo v1.0.1 h1:19N6YogDnf71CTHm3Mp2qhYfkRdyvbgwWdd2EPxJRG4=
github.com/abadojack/whatlanggo v1.0.1/go.mod h1:66WiQbSbJBIlOZMsvbKe5m6pzQovxCH9B/K8tQB2uoc=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
+10 -3
View File
@@ -193,6 +193,7 @@ func main() {
body, _ := io.ReadAll(resp.Body)
res := gjson.ParseBytes(body)
// display response
// fmt.Println(res)
if res.Get("error.code").String() == "-32600" {
@@ -210,10 +211,16 @@ func main() {
"message": "Too Many Requests",
})
} else {
var alternatives []string
res.Get("result.texts.0.alternatives").ForEach(func(key, value gjson.Result) bool {
alternatives = append(alternatives, value.Get("text").String())
return true
})
c.JSON(http.StatusOK, gin.H{
"code": http.StatusOK,
"id": id,
"data": res.Get("result.texts.0.text").String(),
"code": http.StatusOK,
"id": id,
"data": res.Get("result.texts.0.text").String(),
"alternatives": alternatives,
})
}
}