mirror of
https://github.com/OwO-Network/DeepLX.git
synced 2024-11-16 02:22:19 +08:00
feat: add support for regional variant langauges, like pt-BR (#118)
Some checks are pending
CI / Build (push) Waiting to run
Some checks are pending
CI / Build (push) Waiting to run
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 {
|
||||
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{
|
||||
Jsonrpc: "2.0",
|
||||
Method: "LMT_handle_texts",
|
||||
|
@ -21,13 +39,9 @@ func initDeepLXData(sourceLang string, targetLang string) *PostData {
|
|||
Splitting: "newlines",
|
||||
Lang: Lang{
|
||||
SourceLangUserSelected: sourceLang,
|
||||
TargetLang: targetLang,
|
||||
},
|
||||
CommonJobParams: CommonJobParams{
|
||||
WasSpoken: false,
|
||||
TranscribeAS: "",
|
||||
// RegionalVariant: "en-US",
|
||||
TargetLang: targetLangCode,
|
||||
},
|
||||
CommonJobParams: commonJobParams,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
6
types.go
6
types.go
|
@ -24,9 +24,9 @@ type Lang struct {
|
|||
}
|
||||
|
||||
type CommonJobParams struct {
|
||||
WasSpoken bool `json:"wasSpoken"`
|
||||
TranscribeAS string `json:"transcribe_as"`
|
||||
// RegionalVariant string `json:"regionalVariant"`
|
||||
WasSpoken bool `json:"wasSpoken"`
|
||||
TranscribeAS string `json:"transcribe_as"`
|
||||
RegionalVariant string `json:"regionalVariant,omitempty"`
|
||||
}
|
||||
|
||||
type Params struct {
|
||||
|
|
Loading…
Reference in New Issue
Block a user