Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TranslateService ¶
type TranslateService struct {
// set to negative or zero to disable retry
MaximumRetry int
// contains filtered or unexported fields
}
TranslateService provides common functionality for translators, primarily language detection.
func NewTranslateService ¶
func NewTranslateService(conf TranslateServiceConfig) (ts *TranslateService, err error)
func (*TranslateService) DetectLang ¶
func (ts *TranslateService) DetectLang(req detector.DetectRequest) (resp *detector.DetectResponse, name string, err error)
DetectLang attempts to detect the language of the given text. It returns the detected language (ISO 639-1 code), the confidence score.
func (*TranslateService) Translate ¶
func (ts *TranslateService) Translate(req translator.TranslateRequest) (resp *translator.TranslateResponse, name string, err error)
type TranslateServiceConfig ¶
type TranslateServiceConfig struct {
MaximumRetry int `yaml:"max_retry"`
RetryCooldown int `yaml:"retry_cooldown"`
DefaultDetectorConfig detector.DefaultDetectorConfig `yaml:"default_detector_config"`
LanguageDetectorSelector string `yaml:"language_detector_selector"`
LanguageDetectors []detector.DetectorConfig `yaml:"language_detectors"`
DefaultTranslatorConfig translator.DefaultTranslatorConfig `yaml:"default_translator_config"`
TranslatorSelector string `yaml:"translator_selector"`
Translators []translator.TranslatorConfig `yaml:"translators"`
}
TranslateConfig holds all configuration related to translation services.
func NewTranslateServiceConfig ¶
func NewTranslateServiceConfig() (c TranslateServiceConfig)
NewTranslateServiceConfig creates a new TranslateConfig with default empty slices and zero values.
Click to show internal directories.
Click to hide internal directories.