bdfy

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Mar 8, 2024 License: GPL-2.0 Imports: 9 Imported by: 0

Documentation

Overview

百度翻译

Index

Constants

This section is empty.

Variables

View Source
var (
	// 原文
	//	Q string = "apple"
	// 源语言
	From string = "auto"
	// 目标语言
	To string = "zh"

	// 改成您的APP ID
	AppId string = ""
	// 改成您的密钥
	SecretKey string = ""

	Salt string = strconv.Itoa(rand.Intn(65536))

	Bdurl string = "http://api.fanyi.baidu.com/api/trans/vip/translate?"
)
View Source
var (
	Form3 = "en"
	To3   = "zh"

	Lang3 = map[string]string{
		"ar": "阿拉伯语", "de": "德语",
		"ru": "俄语", "fr": "法语",
		"tl": "菲律宾语", "km": "高棉语",
		"kr": "韩语", "lo": "老挝语",
		"pt": "葡萄牙语", "ja": "日语",
		"es": "西班牙语", "it": "意大利语",
		"id": "印度尼西亚语", "en": "英语",
		"vi": "越南语", "zh": "中文",
	}
)

Functions

This section is empty.

Types

type Account

type Account struct {
	Uid       int    `db:"uid"`
	AppId     string `db:"appid"`
	SecretKey string `db:"secretKey"`
}
type Header struct {
	Fn        string `json:"fn"`
	ClientKey string `json:"client_key"`
}

type Header2 added in v0.0.5

type Header2 struct {
	Type      string  `json:"type"`
	RetCode   string  `json:"ret_code"`
	TimeCost  float64 `json:"time_cost"`
	RequestID string  `json:"request_id"`
}

type Source added in v0.0.5

type Source struct {
	Lang     string   `json:"lang"`
	TextList []string `json:"text_list"`
}

type Target added in v0.0.5

type Target struct {
	Lang string `json:"lang"`
}

type Ten added in v0.0.5

type Ten struct {
	Header Header `json:"header"`
	Source Source `json:"source"`
	Target Target `json:"target"`
}

type Trans

type Trans struct {
	From      string `json:"from"`
	To        string `json:"to"`
	ErrorCode string `json:"error_code"`
	ErrorMsg  string `json:"error_msg"`
	Tresult   []struct {
		Src string `json:"src"`
		Dst string `json:"dst"`
	} `json:"trans_result"`
}

func Tr

func Tr(Q string) (Trans, error)

type Tresp added in v0.0.5

type Tresp struct {
	Header          Header2  `json:"header"`
	AutoTranslation []string `json:"auto_translation"`
	Msg             string   `json:"massage"`
}

func Tx added in v0.0.5

func Tx(texts []string) (Tresp, error)

Jump to

Keyboard shortcuts

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