Skip to content

A command-line translation tool written in Go that covers almost all platforms

License

Notifications You must be signed in to change notification settings

7small7/fanyi_go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fanyi_go是一款利用Go语言编写的,聚合类的翻译命令工具,集成阿里、百度、腾讯、星火、微软、谷歌等多家翻译接口。支持Windows系统、Mac系统、Linux系统,只要支持Go语言的操作系统都可以使用。

使用fanyi_go可以实现轻松实现多平台翻译,实现开箱即用的效果。

如何使用

环境要求

fanyi-go考虑到版本向下兼容,在编写时并未使用引入Go语言的高版本语法,因此你几乎是可以在Go的所有版本中运行该项目,不过推荐使用在Go 1.8+的版本。

命令使用

在使用fanyi-go时,你可以通过如下命令,获取到帮助说明。

tutu@tutudeMac-mini ~/p/w/t/fanyi_go (main)> go run main.go -h
-c string
    the content that needs to be translated.
-l string
    the language of the content to be translated has optional values of en (English), zh (Chinese), ja (Japanese) (default "en")
-t string
    the platform used for translation has optional values of bd (Baidu), tx (Tencent), and al (Alibaba). (default "baidu")
  • c 参数表示需要翻译的内容,如何内容比较长,或者是包含了标点符号,可以使用单双引号把内容给包起来,例如-c "你今天晚饭吃的什么呢?"
  • l 参数表示需要翻译内容的语言,可选值为 en (English), zh (Chinese), ja (Japanese),需要遵循一定的规则,内容由当前语言+ 2 + 目标语言组成,例如你要将中文翻译成英文,你可以使用zh2en,其中zh表示中文,en表示英文。每一个平台的格式可能不太一样,具体可以参考文章底部的平台翻译语言对照表。
  • t 参数表示使用的平台,可选值为 bd (Baidu), tx (Tencent), and al (Alibaba)。

** 翻译的结果为自动复制到剪切板中,你可以直接粘贴翻译后的内容。 **

效果预览

# 中文翻译成英文
go run main.go -t tx -c "你好呀!我叫Tom,请问你叫什么名字呢" -l zh2en
Hello! My name is Tom. What's your name, please

# 英文翻译成中文
go run main.go -t tx -c "Good evening,everyone" -l en2zh
大家晚上好

翻译对照表

1、腾讯翻译对照表。文档链接地址

2、阿里翻译对照表。文档链接地址

About

A command-line translation tool written in Go that covers almost all platforms

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages