translation

package
v0.0.0-...-988901e Latest Latest
Warning

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

Go to latest
Published: May 31, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type SanakirjaOrg

type SanakirjaOrg struct {
	// contains filtered or unexported fields
}

SanakirjaOrg is a translator type which scrapes Sanakirja.org.

func NewSanakirjaOrg

func NewSanakirjaOrg(sourceLanguage, targetLanguage language.Tag) (*SanakirjaOrg, error)

NewSanakirjaOrg initializes a new translator for Sanakirja.org. If the given languages are not supported, this returns a non-nil error. Note: Sanakirja.org automatically searches for translations in the opposite direction when there are no results.

func (*SanakirjaOrg) Name

func (t *SanakirjaOrg) Name() string

Name returns the source of the translations.

func (*SanakirjaOrg) Translate

func (t *SanakirjaOrg) Translate(word string) ([]Translation, error)

Translate scrapes Sanakirja.org for translations of the given word.

type Translation

type Translation struct {
	Text    string `json:"text"`
	Context string `json:"context"`
	Grammar string `json:"grammar"`
}

Translation contains all the information returned by a translator. Can be serialized to JSON.

type Translator

type Translator interface {
	Translate(string) ([]Translation, error)
	Name() string
}

Translator is a source for translations.

Jump to

Keyboard shortcuts

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