mirror of
https://github.com/OwO-Network/DeepLX.git
synced 2024-11-16 07:32:20 +08:00
fix: support CommonJobParams
This commit is contained in:
parent
62a993bb13
commit
9edb997f06
|
@ -2,7 +2,7 @@
|
||||||
* @Author: Vincent Young
|
* @Author: Vincent Young
|
||||||
* @Date: 2024-09-16 11:59:24
|
* @Date: 2024-09-16 11:59:24
|
||||||
* @LastEditors: Vincent Yang
|
* @LastEditors: Vincent Yang
|
||||||
* @LastEditTime: 2024-11-01 00:42:43
|
* @LastEditTime: 2024-11-01 12:45:44
|
||||||
* @FilePath: /DeepLX/translate/translate.go
|
* @FilePath: /DeepLX/translate/translate.go
|
||||||
* @Telegram: https://t.me/missuo
|
* @Telegram: https://t.me/missuo
|
||||||
* @GitHub: https://github.com/missuo
|
* @GitHub: https://github.com/missuo
|
||||||
|
@ -161,6 +161,13 @@ func TranslateByDeepLX(sourceLang, targetLang, text string, tagHandling string,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hasRegionalVariant := false
|
||||||
|
targetLangParts := strings.Split(targetLang, "-")
|
||||||
|
targetLangCode := targetLangParts[0]
|
||||||
|
if len(targetLangParts) > 1 {
|
||||||
|
hasRegionalVariant = true
|
||||||
|
}
|
||||||
|
|
||||||
// Prepare translation request
|
// Prepare translation request
|
||||||
id := getRandomNumber()
|
id := getRandomNumber()
|
||||||
postData := &PostData{
|
postData := &PostData{
|
||||||
|
@ -170,16 +177,18 @@ func TranslateByDeepLX(sourceLang, targetLang, text string, tagHandling string,
|
||||||
Params: Params{
|
Params: Params{
|
||||||
CommonJobParams: CommonJobParams{
|
CommonJobParams: CommonJobParams{
|
||||||
Mode: "translate",
|
Mode: "translate",
|
||||||
|
RegionalVariant: map[bool]string{true: targetLang, false: ""}[hasRegionalVariant],
|
||||||
},
|
},
|
||||||
Lang: Lang{
|
Lang: Lang{
|
||||||
SourceLangComputed: strings.ToUpper(sourceLang),
|
SourceLangComputed: strings.ToUpper(sourceLang),
|
||||||
TargetLang: strings.ToUpper(targetLang),
|
TargetLang: strings.ToUpper(targetLangCode),
|
||||||
},
|
},
|
||||||
Jobs: jobs,
|
Jobs: jobs,
|
||||||
Priority: 1,
|
Priority: 1,
|
||||||
Timestamp: getTimeStamp(getICount(text)),
|
Timestamp: getTimeStamp(getICount(text)),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
fmt.Println(postData)
|
||||||
|
|
||||||
// Make translation request
|
// Make translation request
|
||||||
result, err := makeRequest(postData, "LMT_handle_jobs", proxyURL)
|
result, err := makeRequest(postData, "LMT_handle_jobs", proxyURL)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
* @Author: Vincent Young
|
* @Author: Vincent Young
|
||||||
* @Date: 2024-09-16 11:59:24
|
* @Date: 2024-09-16 11:59:24
|
||||||
* @LastEditors: Vincent Yang
|
* @LastEditors: Vincent Yang
|
||||||
* @LastEditTime: 2024-11-01 00:39:49
|
* @LastEditTime: 2024-11-01 12:47:47
|
||||||
* @FilePath: /DeepLX/translate/types.go
|
* @FilePath: /DeepLX/translate/types.go
|
||||||
* @Telegram: https://t.me/missuo
|
* @Telegram: https://t.me/missuo
|
||||||
* @GitHub: https://github.com/missuo
|
* @GitHub: https://github.com/missuo
|
||||||
|
@ -22,6 +22,7 @@ type Lang struct {
|
||||||
// CommonJobParams represents common parameters for translation jobs
|
// CommonJobParams represents common parameters for translation jobs
|
||||||
type CommonJobParams struct {
|
type CommonJobParams struct {
|
||||||
Mode string `json:"mode"`
|
Mode string `json:"mode"`
|
||||||
|
RegionalVariant string `json:"regionalVariant"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sentence represents a sentence in the translation request
|
// Sentence represents a sentence in the translation request
|
||||||
|
|
Loading…
Reference in New Issue
Block a user