translation

package
v0.1.950 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2026 License: Apache-2.0 Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultTradSelector = ".trad"
)

Variables

This section is empty.

Functions

Types

type Blackbox

type Blackbox interface {
	// contains filtered or unexported methods
}

type Client

type Client interface {
	Blackbox
	contract.TranslationOperator
}

func NewClient

func NewClient(ctx context.Context, d Dependencies, opts ClientOptions) (Client, error)

func NewNoopClient added in v0.1.859

func NewNoopClient() Client

type ClientOption

type ClientOption = contract.Opt[ClientOptions]

func WithInitialized

func WithInitialized(x Initialized) ClientOption

type ClientOptions

type ClientOptions struct {
	Initialized
}

func ApplyClientOptions

func ApplyClientOptions(opts *ClientOptions, modifiers ...ClientOption) ClientOptions

type DefaultTool

type DefaultTool struct {
	T *contract.Tool[Client]
}

func NewTool

func NewTool(c Client, opts contract.ToolOptions[Client]) *DefaultTool

func (*DefaultTool) Close

func (d *DefaultTool) Close(ctx context.Context) error

Close closes the underlying translation client.

func (*DefaultTool) ParseLanguage

func (d *DefaultTool) ParseLanguage(ctx context.Context, BCP47Code string) (*language.Tag, error)

ParseLanguage parses a BCP47 language tag and returns a Tag object.

func (*DefaultTool) SuggestBestMatch

func (d *DefaultTool) SuggestBestMatch(ctx context.Context, userLanguage, fallback language.Tag, matcher ...language.Matcher) (*language.Tag, error)

SuggestBestMatch returns the best language match using the default or provided matcher.

func (*DefaultTool) TranslateHTML

func (d *DefaultTool) TranslateHTML(ctx context.Context, opts contract.TranslateHTMLOptions) (io.Reader, error)

TranslateHTML translates HTML content by applying text translations to matched elements.

func (*DefaultTool) TranslateText

func (d *DefaultTool) TranslateText(ctx context.Context, opts contract.TranslateTextOptions) (string, error)

TranslateText translates a single string of text from the source to the target language.

type Dependencies

type Dependencies struct {
	C contract.TranslateClient
}

type Initialized

type Initialized struct {
	Matcher language.Matcher
}

type Loaded

type Loaded struct {
	CredentialsJSON []byte
}

type Tool

type Tool interface {
	contract.TranslationOperator
}

type TranslateClientOptions

type TranslateClientOptions struct {
	Loaded
}

Jump to

Keyboard shortcuts

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