Documentation ¶
Overview ¶
trGo is a rich package for translating a text with a specified language (or detecting it automatically) to another specified language (default is english). It has a simple algorithm (and a readable code).
Index ¶
Constants ¶
const ( TrCmd = "tr" DoubleQS = BackSlash + DoubleQ DoubleQSP = DoubleQS + CAMA NonEscapeN = "\\n" NonEscapeNV = NonEscapeN + CAMA HttpRm = "af.httprm" E4Value = "\"e\"" + CAMA + "4" + CAMA NullCValue = NullStr + CAMA GenericStr = CAMA + "\"generic\"" NullCValueR = CAMA + NullStr NeQ = "\\n\"" NullN = "\n\"" + CAMA + "null" DiValue = "\"di\"" AkCloseQ = "}'" WrbFr = "\"wrb.fr\",\"" + rpcValue + "\"" BoldOpen = "\\u003cb\\u003e" BoldClose = "\\u003c/b\\u003e" MiddleWave = DoubleQSP + DoubleQS WrongNessOpen = `\\u003cb\\u003e\\u003ci\\u003e` WrongNessClose = `\\u003c/i\\u003e\\u003c/b\\u003e` ExampleFirst = "null,\"\\u003cb\\u003e" ThreeE = DoubleBackSlash + "u003e" CeeE = DoubleBackSlash + "u003c" QuetUnicode = "u0026#39;" StrAndCama = DoubleQS + CAMA StringAndCama = DoubleQ + CAMA CamaAndStr = CAMA + DoubleQS NullAndCama = NullStr + CAMA TwoCama = CAMA + CAMA TwoStr = DoubleQ + DoubleQ CamaNullCama = CAMA + NullStr + CAMA )
const ( LineChar = '-' // line : '-' EqualChar = '=' // equal: '=' SpaceChar = ' ' // space: ' ' DPointChar = ':' // double point: ':' )
const ( GET_SLASH = "/" HTTP_ADDRESS = ":" FORMAT_VALUE = "%v" SPACE_VALUE = " " LineEscape = "\n" R_ESCAPE = "\r" SEMICOLON = ";" CAMA = "," ParaOpen = "(" ParaClose = ")" NullStr = "null" DoubleQ = "\"" SingleQ = "'" DoubleQJ = "”" BracketOpen = "[" Bracketclose = "]" Star = "*" BackSlash = "\\" DoubleBackSlash = "\\\\" Point = "." AutoStr = "auto" AtSign = "@" EqualStr = "=" DdotSign = ":" )
router config values
const ( DY = "$" WOTO_TEXT = "WOTO_TEXT" DY_WOTO_TEXT = DY + WOTO_TEXT )
dynamic values
const ( BIN_FLAG = "bin" BINARY_FLAG = "binary" PV_FLAG = "pv" PRIVATE_FLAG = "private" TEXT_FLAG = "text" TXT_FLAG = "txt" TO_FLAG = "to" FR_FLAG = "fr" FROM_FLAG = "from" GNU_FLAG = "gnu" )
the flags for the wotoTranslate plugin. please notice that all flags should begin with prefix --, but in the pTools, this prefix will be removed.
Variables ¶
var MinConfidence float32 = 8.0
Functions ¶
func SimpleTranslate ¶
Types ¶
type Lang ¶
type Lang struct {
Data *LangData `json:"data"`
}
Lang struct contains data of the language.
func DetectLanguage ¶
DetectLanguage will detect the language of a text.
func (*Lang) GetBest ¶
func (l *Lang) GetBest() *LangDetect
type LangData ¶
type LangData struct {
Detections []LangDetect `json:"detections"`
}
LangData contains the data of the language.
type LangDetect ¶
type LangDetect struct { TheLang string `json:"language"` Reliable bool `json:"isReliable"` Confidence float32 `json:"confidence"` }
LangDetect contains the detected languages.
type WotoTr ¶
type WotoTr struct { // Pronunciation of the original text OriginalPronunciation string // Pronunciation of the translated text TranslatedPronunciation string UserText string // Translations is an array of translated string recieved from // google's servers Translations []string From string To string Corrected *Corrected HasWrongness bool // public wrong from. // if 'From' in user's inpur is not correct, // this field will be true. HasWrongFrom bool Kind []string // contains filtered or unexported fields }
WotoTr contains necessary fields for results of a transtion operation.
func TranslateIt ¶
Translate will translate the specified text value tp english.