BaiduTrans

command module
v0.0.0-...-ac4b63c Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2023 License: MIT Imports: 5 Imported by: 0

README

BaiduTrans

官方文档:
https://api.fanyi.baidu.com/
https://api.fanyi.baidu.com/doc/21

通用翻译API HTTPS 地址:
https://fanyi-api.baidu.com/api/trans/vip/translate

go get -u github.com/ArtisanCloud/BaiduTrans

package main

import (
	"github.com/ArtisanCloud/BaiduTrans/config"
	"github.com/ArtisanCloud/BaiduTrans/trans/general"
	"github.com/ArtisanCloud/BaiduTrans/trans/general/request"
	"context"
	"github.com/ArtisanCloud/PowerLibs/v3/fmt"
)

func main() {

	conf := config.Get()

	var err error
	gApp, err := general.NewGeneralTrans(conf)
	if err != nil || gApp == nil {
		panic(err)
	}

	params := &request.RequestGeneralTrans{
		Query: "室内,暗淡,高品质,桌椅,大床",
		From:  "zh",
		To:    "en",
	}
	res, err := gApp.Translate(context.Background(), params)
	if err != nil || gApp == nil {
		panic(err)
	}
	if res.ErrCode != "" {
		panic(res)
	}

	fmt.Dump(res)

	return
}

更多产品:

PowerWechat: https://github.com/ArtisanCloud/PowerWeChat
PowerX: https://github.com/ArtisanCloud/PowerX

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
trans

Jump to

Keyboard shortcuts

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