Skip to content

Commit

Permalink
Support passing a translation context to Deepl
Browse files Browse the repository at this point in the history
  • Loading branch information
Jille authored and bounoable committed Sep 17, 2024
1 parent ad6c5f7 commit a2b5adc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion deepl.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,14 @@ func GlossaryID(glossaryID string) TranslateOption {
}
}

// Context returns a TranslateOption that sets the `context` DeepL
// option.
func Context(context string) TranslateOption {
return func(vals url.Values) {
vals.Set("context", context)
}
}

// New returns a Client that uses authKey as the DeepL authentication key.
func New(authKey string, opts ...ClientOption) *Client {
c := Client{
Expand All @@ -124,7 +132,7 @@ func New(authKey string, opts ...ClientOption) *Client {

// default base url
BaseURL(V2)(&c)

for _, opt := range opts {
opt(&c)
}
Expand Down

0 comments on commit a2b5adc

Please sign in to comment.