trans

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2019 License: MIT Imports: 5 Imported by: 0

README

trans

Go Report Card

Google Translate CLI written in Go.

Required

You must first set up authentication by creating a API Key or service account of GCP.

API Key

The API Key documentation can be found here.

Set the environment variable TRANS_API_KEY to the API Key.

Or Service Account

The service account documentation can be found here.

Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to the file path of the JSON file that contains your service account key.

Note

You need a little bit of money to use google translate API.
e.g. it costs $0.06 for 2889 characters.

Installation

$ go get -u github.com/utahta/trans/cmd/trans

Usage

$ trans -t en こんにちは
Hello
$ trans -t ja this is a pen
これはペンです
$ trans -t ja -r "this is a pen"
これはペンです
this is a pen

Documentation

Index

Constants

View Source
const (
	EnvTransAPIKey = "TRANS_API_KEY"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	*translate.Client
}

Client represents google translate api client

func New

func New(ctx context.Context, opts ...option.ClientOption) (*Client, error)

New returns Client

func (*Client) Translate

func (c *Client) Translate(ctx context.Context, input string, s string, t string, reverse bool) (string, error)

Translate translates input text

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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