baidu

package
v0.0.0-...-575d2ff Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 6, 2022 License: Unlicense Imports: 16 Imported by: 0

README

百度翻译 api

同一接口,可以接受一个或者多个词语

Documentation

Overview

export two method

Index

Constants

This section is empty.

Variables

View Source
var (
	BaiduTranslater BaiduTranslate
	QueryChan       chan string //独立的 query
	MergeQueryChan  chan string //合并后的 query

)

Functions

This section is empty.

Types

type BaiDuTranslateResule

type BaiDuTranslateResule struct {
	From         string        `json:"from"`
	To           string        `json:"to"`
	Trans_result []FanyiResult `json:"trans_result"`
	Error_code   string        `json:"error_code"`
	Error_msg    string        `json:"error_msg"`
}

type BaiduTransEnToZh

type BaiduTransEnToZh struct {
	UpdatedAt time.Time `gorm:"autoUpdateTime"`
	Src       string    `gorm:"primaryKey"`
	Dst       string
}

type BaiduTranslate

type BaiduTranslate struct {
	Appid  string
	Secret string
	// contains filtered or unexported fields
}

func NewBaiduTranslater

func NewBaiduTranslater(Appid, Secret string, setmeal SetMeal, lang Lang) *BaiduTranslate

func (*BaiduTranslate) Translate

func (c *BaiduTranslate) Translate(querys []string) []string

translate mulit word, rsync filter \n

func (*BaiduTranslate) TranslateOne

func (c *BaiduTranslate) TranslateOne(query string) string

translate One query

type FanyiResult

type FanyiResult map[string]string

type Lang

type Lang string
const (
	ZH Lang = "zh"
	EN Lang = "en"
)

type SetMeal

type SetMeal uint
const (
	Standard SetMeal = iota
	Senior
	Premium
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL