Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommonJobParams ¶
type CommonJobParams struct {
Formality string `json:"formality"` // Can be "undefined"
TranscribeAs string `json:"transcribe_as"`
Mode string `json:"mode"`
WasSpoken bool `json:"wasSpoken"`
AdvancedMode bool `json:"advancedMode"`
TextType string `json:"textType"`
RegionalVariant string `json:"regionalVariant,omitempty"`
}
CommonJobParams represents common parameters for translation jobs
type DeepLXTranslationResult ¶
type DeepLXTranslationResult struct {
Code int `json:"code"`
ID int64 `json:"id"`
Message string `json:"message,omitempty"`
Data string `json:"data"` // The primary translated text
Alternatives []string `json:"alternatives"` // Other possible translations
SourceLang string `json:"source_lang"`
TargetLang string `json:"target_lang"`
Method string `json:"method"`
}
DeepLXTranslationResult represents the final translation result
func TranslateByDeepLX ¶
func TranslateByDeepLX(sourceLang, targetLang, text string, tagHandling string, proxyURL string, dlSession string) (DeepLXTranslationResult, error)
TranslateByDeepLX performs translation using DeepL API
type Job ¶ added in v0.9.9
type Job struct {
Kind string `json:"kind"`
PreferredNumBeams int `json:"preferred_num_beams"`
RawEnContextBefore []string `json:"raw_en_context_before"`
RawEnContextAfter []string `json:"raw_en_context_after"`
Sentences []Sentence `json:"sentences"`
}
Job represents a translation job
type Lang ¶
type Lang struct {
SourceLangUserSelected string `json:"source_lang_user_selected"` // Can be "auto"
TargetLang string `json:"target_lang"`
SourceLangComputed string `json:"source_lang_computed,omitempty"`
}
Lang represents the language settings for translation
type LegacyParams ¶ added in v1.0.8
type LegacyParams struct {
CommonJobParams CommonJobParams `json:"commonJobParams"`
Lang Lang `json:"lang"`
Jobs []Job `json:"jobs"`
Timestamp int64 `json:"timestamp"`
}
LegacyParams represents the old parameters structure for jobs (kept for compatibility)
type LegacyTranslationResponse ¶ added in v1.0.8
type LegacyTranslationResponse struct {
Jsonrpc string `json:"jsonrpc"`
ID int64 `json:"id"`
Result struct {
Translations []struct {
Beams []struct {
Sentences []SentenceResponse `json:"sentences"`
NumSymbols int `json:"num_symbols"`
RephraseVariant struct {
Name string `json:"name"`
} `json:"rephrase_variant"`
} `json:"beams"`
Quality string `json:"quality"` // Added quality
} `json:"translations"`
TargetLang string `json:"target_lang"`
SourceLang string `json:"source_lang"`
SourceLangIsConfident bool `json:"source_lang_is_confident"`
DetectedLanguages map[string]interface{} `json:"detectedLanguages"` // Use interface{} for now
} `json:"result"`
}
LegacyTranslationResponse represents the old response format (kept for compatibility)
type Params ¶
type Params struct {
Splitting string `json:"splitting"`
Lang Lang `json:"lang"`
Texts []TextItem `json:"texts"`
Timestamp int64 `json:"timestamp"`
}
Params represents parameters for translation requests
type PostData ¶
type PostData struct {
Jsonrpc string `json:"jsonrpc"`
Method string `json:"method"`
ID int64 `json:"id"`
Params Params `json:"params"`
}
PostData represents the complete translation request
type SentenceResponse ¶ added in v1.0.6
SentenceResponse is a helper struct for the response sentences
type TextItem ¶ added in v1.0.8
type TextItem struct {
Text string `json:"text"`
RequestAlternatives int `json:"requestAlternatives"`
}
TextItem represents a text item for translation
type TextResponse ¶ added in v1.0.8
type TextResponse struct {
Text string `json:"text"`
Alternatives []struct {
Text string `json:"text"`
} `json:"alternatives"`
}
TextResponse represents a single text response
type TranslationResponse ¶
type TranslationResponse struct {
Jsonrpc string `json:"jsonrpc"`
ID int64 `json:"id"`
Result struct {
Lang string `json:"lang"`
Texts []TextResponse `json:"texts"`
} `json:"result"`
}
TranslationResponse represents the response from LMT_handle_texts