engines

package module
v0.0.0-...-526a2c0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Engines = map[string]Engine{
	"google": &GoogleTranslate{},

	"reverso": &Reverso{},
}

Functions

This section is empty.

Types

type Engine

type Engine interface {
	DisplayName() string
	SourceLanguages() (Language, error)
	TargetLanguages() (Language, error)
	Translate(text string, from, to string) (TranslationResult, error)
	Tts(text, lang string) (string, error)
}

type GoogleTranslate

type GoogleTranslate struct{}

func (*GoogleTranslate) DisplayName

func (_ *GoogleTranslate) DisplayName() string

func (*GoogleTranslate) SourceLanguages

func (e *GoogleTranslate) SourceLanguages() (Language, error)

func (*GoogleTranslate) TargetLanguages

func (e *GoogleTranslate) TargetLanguages() (Language, error)

func (*GoogleTranslate) Translate

func (_ *GoogleTranslate) Translate(text string, from, to string) (TranslationResult, error)

func (*GoogleTranslate) Tts

func (e *GoogleTranslate) Tts(text, lang string) (string, error)

type ICIBA

type ICIBA struct{}

ICIBA is an engine that fetches data from https://www.iciba.com.

func (*ICIBA) DisplayName

func (_ *ICIBA) DisplayName() string

func (*ICIBA) SourceLanguages

func (_ *ICIBA) SourceLanguages() (Language, error)

func (*ICIBA) TargetLanguages

func (_ *ICIBA) TargetLanguages() (Language, error)

func (*ICIBA) Translate

func (_ *ICIBA) Translate(text string, from, to string) (TranslationResult, error)

func (*ICIBA) Tts

func (_ *ICIBA) Tts(text, lang string) (string, error)

type Language

type Language map[string]string

type LibreTranslate

type LibreTranslate struct {
	// InstanceURL is the URL to a LibreTranslate instance, for example
	// "https://libretranslate.com".
	InstanceURL string
	// APIKey is the API key for the given instance. If empty, then no API
	// key will be sent along with requests to the instance.
	//
	// Some instances issue API keys to users so that they can have a
	// higher rate limit. See
	// https://github.com/LibreTranslate/LibreTranslate#manage-api-keys for
	// more information.
	APIKey string
}

LibreTranslate is an engine that interfaces with any LibreTranslate(https://github.com/LibreTranslate/LibreTranslate) instance.

func (*LibreTranslate) DisplayName

func (_ *LibreTranslate) DisplayName() string

func (*LibreTranslate) SourceLanguages

func (e *LibreTranslate) SourceLanguages() (Language, error)

func (*LibreTranslate) TargetLanguages

func (e *LibreTranslate) TargetLanguages() (Language, error)

func (*LibreTranslate) Translate

func (e *LibreTranslate) Translate(text string, from, to string) (TranslationResult, error)

func (*LibreTranslate) Tts

func (e *LibreTranslate) Tts(text, lang string) (string, error)

type Reverso

type Reverso struct{}

Reverso is an engine that fetches data from https://reverso.net.

func (*Reverso) DisplayName

func (_ *Reverso) DisplayName() string

func (*Reverso) SourceLanguages

func (_ *Reverso) SourceLanguages() (Language, error)

func (*Reverso) TargetLanguages

func (_ *Reverso) TargetLanguages() (Language, error)

func (*Reverso) Translate

func (e *Reverso) Translate(text string, from, to string) (TranslationResult, error)

func (*Reverso) Tts

func (_ *Reverso) Tts(text, lang string) (string, error)

type TranslationResult

type TranslationResult struct {
	SourceLanguage string      `json:"source_language"`
	Definitions    interface{} `json:"definitions"`
	Translations   interface{} `json:"translations"`
	TranslatedText string      `json:"translated_text"`
}

Jump to

Keyboard shortcuts

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