mirror of
https://github.com/OwO-Network/DeepLX.git
synced 2025-04-19 06:03:25 +00:00
feat: add support for regional variant langauges, like pt-BR (#118)
This commit is contained in:
parent
93a3204eab
commit
8bf6d05603
26
translate.go
26
translate.go
@ -14,6 +14,24 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func initDeepLXData(sourceLang string, targetLang string) *PostData {
|
func initDeepLXData(sourceLang string, targetLang string) *PostData {
|
||||||
|
hasRegionalVariant := false
|
||||||
|
targetLangParts := strings.Split(targetLang, "-")
|
||||||
|
|
||||||
|
// targetLang can be "en", "pt", "pt-PT", "pt-BR"
|
||||||
|
// targetLangCode is the first part of the targetLang, e.g. "pt" in "pt-PT"
|
||||||
|
targetLangCode := targetLangParts[0]
|
||||||
|
if len(targetLangParts) > 1 {
|
||||||
|
hasRegionalVariant = true
|
||||||
|
}
|
||||||
|
|
||||||
|
commonJobParams := CommonJobParams{
|
||||||
|
WasSpoken: false,
|
||||||
|
TranscribeAS: "",
|
||||||
|
}
|
||||||
|
if hasRegionalVariant {
|
||||||
|
commonJobParams.RegionalVariant = targetLang
|
||||||
|
}
|
||||||
|
|
||||||
return &PostData{
|
return &PostData{
|
||||||
Jsonrpc: "2.0",
|
Jsonrpc: "2.0",
|
||||||
Method: "LMT_handle_texts",
|
Method: "LMT_handle_texts",
|
||||||
@ -21,13 +39,9 @@ func initDeepLXData(sourceLang string, targetLang string) *PostData {
|
|||||||
Splitting: "newlines",
|
Splitting: "newlines",
|
||||||
Lang: Lang{
|
Lang: Lang{
|
||||||
SourceLangUserSelected: sourceLang,
|
SourceLangUserSelected: sourceLang,
|
||||||
TargetLang: targetLang,
|
TargetLang: targetLangCode,
|
||||||
},
|
|
||||||
CommonJobParams: CommonJobParams{
|
|
||||||
WasSpoken: false,
|
|
||||||
TranscribeAS: "",
|
|
||||||
// RegionalVariant: "en-US",
|
|
||||||
},
|
},
|
||||||
|
CommonJobParams: commonJobParams,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
6
types.go
6
types.go
@ -24,9 +24,9 @@ type Lang struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type CommonJobParams struct {
|
type CommonJobParams struct {
|
||||||
WasSpoken bool `json:"wasSpoken"`
|
WasSpoken bool `json:"wasSpoken"`
|
||||||
TranscribeAS string `json:"transcribe_as"`
|
TranscribeAS string `json:"transcribe_as"`
|
||||||
// RegionalVariant string `json:"regionalVariant"`
|
RegionalVariant string `json:"regionalVariant,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Params struct {
|
type Params struct {
|
||||||
|
Loading…
Reference in New Issue
Block a user