interpreter

package module
v0.0.0-...-79a5390 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2017 License: GPL-3.0 Imports: 7 Imported by: 0

README

interpretor

A simple interpretor using goolgle translate.

example use

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)
}

output is

你好,世界
Hello world!

install

go get github.com/fyh/interpretor

documentation

see http://godoc.org/github.com/fyh/interpretor

Documentation

Index

Constants

View Source
const (
	EN    = "en"
	ZH_TW = "zh-TW"
	ZH_CN = "zh-CN"
)

ISO-639-1 Code See: https://cloud.google.com/translate/docs/languages

Variables

This section is empty.

Functions

func Translate

func Translate(t string, tl string) (string, error)

Translate for simple translation like `interpretor.Translate("hello, world", interpretor.zh_CN)` source language is automaticly detected with `auto` mark

func Version

func Version() string

returns the current implementation version

Types

type Interpreter

type Interpreter struct {
	// contains filtered or unexported fields
}

func New

func New() *Interpreter

New returns a pointer to a new, empty `Interpreter` object

func NewText

func NewText(t string, tl string) *Interpreter

New returns a pointer to a new, empty `Interpreter` object

func (*Interpreter) Append

func (i *Interpreter) Append(t string)

Append append text `t` to the interpretor

func (*Interpreter) Interpret

func (i *Interpreter) Interpret() (string, error)

Interpret interpret source text `t`

func (i *Interpreter) Link() string

Link returns the request url of google translate

Jump to

Keyboard shortcuts

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