# youdaotrans **Repository Path**: EEPPEE_admin/youdaotrans ## Basic Information - **Project Name**: youdaotrans - **Description**: youdao cli translator - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: go-version - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2023-12-18 - **Last Updated**: 2026-01-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: youdao-translate ## README # youdao cli translator - for my own usage - **leak api key** so far but I don't fucking care # build ```bash go build -o youdaotrans cmd/main.go ``` # cli usage ```bash ./youdaotrans --help 有道翻译CLI工具 支持功能: 1. 多语言互译(自动识别源语言) 2. 指定源语言/目标语言 3. 智能输入:命令行参数 > 剪贴板 > 标准输入 4. 翻译进度显示 5. 扩展释义展示 支持的语言码:auto(自动), zh(中文), en(英文), ja(日语), ko(韩语), fr(法语), de(德语), ru(俄语), es(西班牙语) Usage: youdaotrans [flags] youdaotrans [command] Available Commands: completion Generate the autocompletion script for the specified shell help Help about any command translate 翻译指定文本(核心功能) Flags: -f, --from string 源语言(如:zh, en, ja,默认auto) (default "auto") -h, --help help for youdaotrans -t, --to string 目标语言(如:zh, en, ja,默认auto) (default "auto") -v, --version version for youdaotrans Use "youdaotrans [command] --help" for more information about a command. ``` # package usage ```golang package main import ( "fmt" "strings" "time" "gitee.com/EEPPEE_admin/youdaotrans" // Replace with your actual module path ) func main() { // 1. Initialize client (replace with your actual Youdao appKey/appSecret) appKey := "PUT YOUR APP KEY HERE" appSecret := "PUT YOUR APP SECRET HERE" client := youdaotrans.NewClient(appKey, appSecret, 15*time.Second) // Optional: Custom User-Agent client.SetUserAgent("MyTranslator/1.0") // 2. Simple translation (English → Chinese) text := "Hello World" result, err := client.TranslateSimple(text, "en", "zh") if err != nil { fmt.Printf("Simple translation failed: %v\n", err) return } fmt.Printf("Original: %s\nTranslation: %s\n\n", text, result) // 3. Batch translation (multiple texts, auto-detect → Japanese) texts := []string{"Go is a great language", "I love programming"} results, err := client.Translate(texts, "auto", "ja") if err != nil { fmt.Printf("Batch translation failed: %v\n", err) return } // Print batch results for i, res := range results { fmt.Printf("Original[%d]: %s\n", i, texts[i]) fmt.Printf("Translation[%d]: %s\n", i, res.Translation[0]) // Print extended definitions (Youdao-specific) if len(res.ParaphraseList) > 0 { fmt.Println("Extended Definitions:") for _, paraphrase := range res.ParaphraseList { fmt.Printf(" %s: %s\n", paraphrase.Key, strings.Join(paraphrase.Value, ", ")) } } fmt.Println() } } ``` # todo 1. should I support read text from file to translate 2. mainly only support between zh <-> en, I don't fucking care too much