The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
4357

一个 google translate 翻译工具

  •  
  •   4357 · Jun 23, 2017 · 2390 views
    This topic created in 3247 days ago, the information mentioned may be changed or developed.

    https://github.com/fyh/interpretor

    实现:请求 google translate,翻译结果是一个 json 数组,拼接起来即可。

    示例:

    package main
    
    import (
        "fmt"
        "github.com/fyh/interpretor"
    )
    
    func main()  {
        i, _ := interpreter.Translate("hello, world", interpreter.ZH_CN)
        fmt.Println(i)
    
        i, _ = interpreter.Translate("你好,世界!", interpreter.EN)
        fmt.Println(i)
    }
    

    输出

    你好,世界
    Hello world!
    

    希望有用,轻喷。

    3 replies    2017-06-23 10:08:48 +08:00
    unique
        1
    unique  
       Jun 23, 2017 via iPhone
    支持一下楼主
    4357
        2
    4357  
    OP
       Jun 23, 2017 via iPhone
    @unique 谢谢
    pathletboy
        3
    pathletboy  
       Jun 23, 2017
    默认的 http client 没有 timeout 的,运气不好就会卡死了。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1221 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 31ms · UTC 17:37 · PVG 01:37 · LAX 10:37 · JFK 13:37
    ♥ Do have faith in what you're doing.