translate

package
v0.0.0-...-60b0928 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

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

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL