Documentation ¶
Index ¶
- Constants
- func DisableOutlineDetection() lang.TranslateOption
- func Formal() lang.TranslateOption
- func GlossaryId(o string) lang.TranslateOption
- func IgnoreTags(tags ...string) lang.TranslateOption
- func Informal() lang.TranslateOption
- func NonSplittingTags(tags ...string) lang.TranslateOption
- func PreserveFormatting() lang.TranslateOption
- func SourceLanguage(o lang.Language) lang.TranslateOption
- func SplitSentences(o string) lang.TranslateOption
- func SplittingTags(tags ...string) lang.TranslateOption
- func TagHandling() lang.TranslateOption
- type Client
- type ClientOption
- type Translation
- type TranslationResponse
Constants ¶
const (
// Version of the client
Version = "v2"
)
Variables ¶
This section is empty.
Functions ¶
func DisableOutlineDetection ¶
func DisableOutlineDetection() lang.TranslateOption
DisableOutlineDetection The automatic detection of the XML structure won't yield best results in all XML files. You can disable this automatic mechanism altogether by setting the outline_detection parameter to 0 and selecting the tags that should be considered structure tags. This will split sentences using the splitting_tags parameter.
func Formal ¶
func Formal() lang.TranslateOption
Formal Sets the formality to more formal Sets whether the translated text should lean towards formal or informal language. This feature currently only works for target languages "DE" (German), "FR" (French), "IT" (Italian), "ES" (Spanish), "NL" (Dutch), "PL" (Polish), "PT-PT", "PT-BR" (Portuguese) and "RU" (Russian).
func GlossaryId ¶
func GlossaryId(o string) lang.TranslateOption
GlossaryId Specify the glossary to use for the translation. Important: This requires the source_lang parameter to be set and the language pair of the glossary has to match the language pair of the request.
func IgnoreTags ¶
func IgnoreTags(tags ...string) lang.TranslateOption
IgnoreTags Comma-separated list of XML tags that indicate text not to be translated.
func Informal ¶
func Informal() lang.TranslateOption
Informal Sets the formality to less formal Sets whether the translated text should lean towards formal or informal language. This feature currently only works for target languages "DE" (German), "FR" (French), "IT" (Italian), "ES" (Spanish), "NL" (Dutch), "PL" (Polish), "PT-PT", "PT-BR" (Portuguese) and "RU" (Russian).
func NonSplittingTags ¶
func NonSplittingTags(tags ...string) lang.TranslateOption
NonSplittingTags Comma-separated list of XML tags which never split sentences.
func PreserveFormatting ¶
func PreserveFormatting() lang.TranslateOption
PreserveFormatting Sets whether the translation engine should respect the original formatting, even if it would usually correct some aspects.
func SourceLanguage ¶
func SourceLanguage(o lang.Language) lang.TranslateOption
SourceLanguage Language of the text to be translated
func SplitSentences ¶
func SplitSentences(o string) lang.TranslateOption
SplitSentences Sets whether the translation engine should first split the input into sentences. This is enabled by default.
func SplittingTags ¶
func SplittingTags(tags ...string) lang.TranslateOption
SplittingTags Comma-separated list of XML tags which always cause splits.
func TagHandling ¶
func TagHandling() lang.TranslateOption
TagHandling Sets which kind of tags should be handled.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client for the DeepL Pro API
func NewClient ¶
func NewClient(authKey string, opts ...ClientOption) *Client
NewClient creates a new client instance for the DeepL Pro API
func (Client) Translate ¶
func (c Client) Translate(ctx context.Context, text string, targetLanguage lang.Language, opts ...lang.TranslateOption) (*lang.Text, error)
Translate is an API service that allows to translate texts and is available at https://api-free.deepl.com/v2/translate. Documentation: https://www.deepl.com/docs-api/translating-text/
type ClientOption ¶
type ClientOption func(c *Client)
ClientOption for custom client configuration
func HttpClient ¶
func HttpClient(o *http.Client) ClientOption
HttpClient sets a custom http client for the client
type Translation ¶
type Translation struct { // DetectedSourceLanguage The language detected in the source text. It reflects the value of the source_lang parameter, when specified. DetectedSourceLanguage string `json:"detected_source_language"` // Text The translated text. Text string `json:"text"` }
Translation A single instance of translated text
type TranslationResponse ¶
type TranslationResponse struct {
Translations []Translation `json:"translations"`
}
TranslationResponse List of the translations in the order the text parameters have been specified.