Documentation
¶
Overview ¶
Written by @z3ntl3 under GNU license
License: see LICENSE file
Index ¶
Constants ¶
View Source
const ( API_URL = "https://translate.google.com/translate_a/single" DstTarget = "t" )
Variables ¶
This section is empty.
Functions ¶
func Translate ¶
func Translate[T any, Trans GoogleTranslator[T]](instance Trans, options TranslationOptions) (string, error)
Starts the translation handshake. Works with every GoogleTranslator instance that comforts the interface
Returns translation string in targetLang or error if any
Types ¶
type Client ¶
GoogleTranslator client
func (*Client) ClearProxy ¶
Clears the proxy so that it is not used on the google translator instance when translating
type GoogleTranslator ¶
type GoogleTranslator[T any] interface { SetProxy(string) (*T, error) ClearProxy() *T SetTimeout(time.Duration) *T Translate(TranslationOptions) (string, error) }
Comes into handy when you want to implement your own GoogleTranslator instead of the current internal one
type TranslationOptions ¶
type TranslationOptions struct { Client string `url:"client"` // Client, should be 'gtx' SourceLang string `url:"sl"` // Source language TargetLang string `url:"tl"` // Target language DstTarget string `url:"dt"` // Destination target, should be 't' Query string `url:"q"` // Query (text to translate from source lang to target lang) }
Translation options Gets encoded in query string
Click to show internal directories.
Click to hide internal directories.