Documentation
¶
Index ¶
- Constants
- func NewTranslateClient(ctx context.Context, retryOpts helper.RetryOptions, ...) (contract.TranslateClient, error)
- type Blackbox
- type Client
- type ClientOption
- type ClientOptions
- type DefaultTool
- func (d *DefaultTool) Close(ctx context.Context) error
- func (d *DefaultTool) ParseLanguage(ctx context.Context, BCP47Code string) (*language.Tag, error)
- func (d *DefaultTool) SuggestBestMatch(ctx context.Context, userLanguage, fallback language.Tag, ...) (*language.Tag, error)
- func (d *DefaultTool) TranslateHTML(ctx context.Context, opts contract.TranslateHTMLOptions) (io.Reader, error)
- func (d *DefaultTool) TranslateText(ctx context.Context, opts contract.TranslateTextOptions) (string, error)
- type Dependencies
- type Initialized
- type Loaded
- type Tool
- type TranslateClientOptions
Constants ¶
View Source
const (
DefaultTradSelector = ".trad"
)
Variables ¶
This section is empty.
Functions ¶
func NewTranslateClient ¶
func NewTranslateClient(ctx context.Context, retryOpts helper.RetryOptions, opts TranslateClientOptions) (contract.TranslateClient, error)
Types ¶
type Client ¶
type Client interface {
Blackbox
contract.TranslationOperator
}
func NewClient ¶
func NewClient(ctx context.Context, d Dependencies, opts ClientOptions) (Client, error)
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 ¶
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 ¶
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 Tool ¶
type Tool interface {
contract.TranslationOperator
}
type TranslateClientOptions ¶
type TranslateClientOptions struct {
Loaded
}
Click to show internal directories.
Click to hide internal directories.