Skip to content

Commit 44b6c29

Browse files
committed
fix: while sourceLang is auto
1 parent b89751f commit 44b6c29

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

go.mod

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module github.com/OwO-Network/DeepLX
33
go 1.23.3
44

55
require (
6+
github.com/abadojack/whatlanggo v1.0.1
67
github.com/andybalholm/brotli v1.1.0
78
github.com/gin-contrib/cors v1.6.0
89
github.com/gin-gonic/gin v1.9.1

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
github.com/abadojack/whatlanggo v1.0.1 h1:19N6YogDnf71CTHm3Mp2qhYfkRdyvbgwWdd2EPxJRG4=
2+
github.com/abadojack/whatlanggo v1.0.1/go.mod h1:66WiQbSbJBIlOZMsvbKe5m6pzQovxCH9B/K8tQB2uoc=
13
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
24
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
35
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=

translate/translate.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* @Author: Vincent Young
33
* @Date: 2024-09-16 11:59:24
44
* @LastEditors: Vincent Yang
5-
* @LastEditTime: 2024-11-01 23:19:11
5+
* @LastEditTime: 2024-12-03 11:23:23
66
* @FilePath: /DeepLX/translate/translate.go
77
* @Telegram: https://t.me/missuo
88
* @GitHub: https://github.com/missuo
@@ -15,12 +15,14 @@ package translate
1515
import (
1616
"bytes"
1717
"fmt"
18-
"github.com/imroc/req/v3"
1918
"io"
2019
"net/http"
2120
"net/url"
2221
"strings"
2322

23+
"github.com/abadojack/whatlanggo"
24+
"github.com/imroc/req/v3"
25+
2426
"github.com/andybalholm/brotli"
2527
"github.com/tidwall/gjson"
2628
)
@@ -135,7 +137,7 @@ func TranslateByDeepLX(sourceLang, targetLang, text string, tagHandling string,
135137

136138
// Get detected language if source language is auto
137139
if sourceLang == "auto" || sourceLang == "" {
138-
sourceLang = strings.ToLower(splitResult.Get("result.lang.detected").String())
140+
sourceLang = strings.ToUpper(whatlanggo.DetectLang(text).Iso6391())
139141
}
140142

141143
// Prepare jobs from split result

0 commit comments

Comments
 (0)