Documentation ¶
Index ¶
- Constants
- Variables
- func HandleHTTPError(resp *http.Response) error
- type Client
- func (c *Client) CheckDocumentStatus(ctx context.Context, documentID, documentKey string) (*DocumentStatus, error)
- func (c *Client) CreateGlossary(ctx context.Context, name, sourceLang, targetLang, entries string, ...) (*Glossary, error)
- func (c *Client) Delete(ctx context.Context, path string) (*http.Response, error)
- func (c *Client) DeleteGlossary(ctx context.Context, glossaryID string) error
- func (c *Client) Do(req *http.Request, v any) (*http.Response, error)
- func (c *Client) DownloadTranslatedDocument(ctx context.Context, documentID, documentKey string) ([]byte, error)
- func (c *Client) Get(ctx context.Context, path string, query url.Values, v any) (*http.Response, error)
- func (c *Client) GetGlossaries(ctx context.Context) (*Glossaries, error)
- func (c *Client) GetGlossary(ctx context.Context, glossaryID string) (*Glossary, error)
- func (c *Client) GetGlossaryEntries(ctx context.Context, glossaryID string) ([]GlossaryEntry, error)
- func (c *Client) GetGlossaryLanguagesPairs(ctx context.Context) (*GlossaryLanguagePairs, error)
- func (c *Client) GetLanguages(ctx context.Context, langType langType) ([]Language, error)
- func (c *Client) GetUsage(ctx context.Context) (*Usage, error)
- func (c *Client) NewRequest(ctx context.Context, method, path string, query url.Values, body io.Reader) (*http.Request, error)
- func (c *Client) Post(ctx context.Context, path string, body io.Reader, v any) (*http.Response, error)
- func (c *Client) TranslateText(ctx context.Context, text []string, targetLang string, option TranslateOption) (*Translations, error)
- func (c *Client) UploadFile(ctx context.Context, path string, body io.Reader, v any) (*http.Response, error)
- func (c *Client) UploadTranslateDocument(ctx context.Context, filePath, targetLang string, ...) (*DocumentInfo, error)
- type DocumentInfo
- type DocumentStatus
- type EntriesFormat
- type Glossaries
- type Glossary
- type GlossaryEntries
- type GlossaryEntry
- type GlossaryLanguagePairs
- type HTTPError
- type Language
- type TranslateDocumentOption
- type TranslateOption
- type Translations
- type Usage
Constants ¶
View Source
const ( Version = "v0.0.1" ProAPIHost = "https://api.deepl.com" FreeAPIHost = "https://api-free.deepl.com" APIVersion = "v2" )
View Source
const ( Source langType = "source" Target langType = "target" )
Variables ¶
View Source
var ( CSV csvFormat TSV tsvFormat )
Functions ¶
func HandleHTTPError ¶
Types ¶
type Client ¶
func (*Client) CheckDocumentStatus ¶
func (*Client) CreateGlossary ¶
func (*Client) DeleteGlossary ¶
func (*Client) DownloadTranslatedDocument ¶
func (*Client) GetGlossaries ¶
func (c *Client) GetGlossaries(ctx context.Context) (*Glossaries, error)
func (*Client) GetGlossary ¶
func (*Client) GetGlossaryEntries ¶
func (*Client) GetGlossaryLanguagesPairs ¶
func (c *Client) GetGlossaryLanguagesPairs(ctx context.Context) (*GlossaryLanguagePairs, error)
func (*Client) GetLanguages ¶
func (*Client) NewRequest ¶
func (*Client) TranslateText ¶
func (c *Client) TranslateText(ctx context.Context, text []string, targetLang string, option TranslateOption) (*Translations, error)
func (*Client) UploadFile ¶
func (c *Client) UploadFile(ctx context.Context, path string, body io.Reader, v any) (*http.Response, error)
TODO
func (*Client) UploadTranslateDocument ¶
func (c *Client) UploadTranslateDocument(ctx context.Context, filePath, targetLang string, option *TranslateDocumentOption) (*DocumentInfo, error)
type DocumentInfo ¶
type DocumentStatus ¶
type EntriesFormat ¶
type Glossaries ¶
type Glossaries struct {
Glossaries []Glossary `json:"glossaries"`
}
type GlossaryEntries ¶
type GlossaryEntries []GlossaryEntry
func DecodeGlossaryEntries ¶
func DecodeGlossaryEntries(r io.Reader) (GlossaryEntries, error)
func NewGlossaryEntries ¶
func NewGlossaryEntries(args ...GlossaryEntry) GlossaryEntries
func (GlossaryEntries) EncodeGlossaryEntries ¶
func (ges GlossaryEntries) EncodeGlossaryEntries(format EntriesFormat) string
type GlossaryEntry ¶
type GlossaryLanguagePairs ¶
type TranslateDocumentOption ¶
type TranslateOption ¶
type TranslateOption struct { SourceLang string `json:"source_lang,omitempty"` Context string `json:"context,omitempty"` SplitSentences string `json:"split_sentences,omitempty"` PreserveFormatting bool `json:"preserve_formatting,omitempty"` Formality string `json:"formality,omitempty"` GlossaryID string `json:"glossary_id,omitempty"` TagHandling string `json:"tag_handling,omitempty"` OutlineDetection bool `json:"outline_detection,omitempty"` NonSplittingTags []string `json:"non_splitting_tags,omitempty"` SplittingTags []string `json:"splitting_tags,omitempty"` IgnoreTags []string `json:"ignore_tags,omitempty"` }
TODO: to Functional Option Pattern
type Translations ¶
type Usage ¶
type Usage struct { CharacterCount int `json:"character_count"` CharacterLimit int `json:"character_limit"` DocumentCount int `json:"document_count,omitempty"` DocumentLimit int `json:"document_limit,omitempty"` TeamDocumentCount int `json:"team_document_count,omitempty"` TeamDocumentLimit int `json:"team_document_limit,omitempty"` }
Source Files ¶
Click to show internal directories.
Click to hide internal directories.