translate

command module
v0.0.0-...-b57808c Latest Latest
Warning

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

Go to latest
Published: May 24, 2019 License: MIT Imports: 10 Imported by: 0

README

Translation tool

GoDoc Build Status codecov Docker Pulls Release

This is a translation tool for translating content from input file into target language by using google cloud translate.

Currently support json, yaml, html and plain text formats.

The supported json format is:

{
    "key1": "value1",
    "key2": "value2",
    ...
}

The supported yaml format is:

key1: value1
key2: value2
...

Run by docker

  1. Print usage
docker run --rm dakalab/translate -h
  1. Get available languages:
docker run --rm -e GCLOUD_API_KEY=your-key dakalab/translate -l
  1. Translate
docker run --rm -e GCLOUD_API_KEY=your-key dakalab/translate -i "input-file" -o "output-file" -s source-language -t target-language

Below is a simple example which will translate the demo.json into Chinese and output to stdout:

docker run --rm -e GCLOUD_API_KEY=your-key -v $PWD/testfiles/demo.json:/demo.json dakalab/translate -i "/demo.json" -s en -t zh

Example of translating yaml file:

docker run --rm -e GCLOUD_API_KEY=your-key -v $PWD/testfiles/demo.yml:/demo.yml dakalab/translate -i "/demo.yml" -s en -t zh

Example of translating html file:

docker run --rm -e GCLOUD_API_KEY=your-key -v $PWD/testfiles/demo.txt:/demo.html dakalab/translate -i "/demo.html" -s en -t zh

Run by local golang

Install
go get -u github.com/dakalab/translate
Usage
  1. Print usage
translate -h
  1. Get available languages:
GCLOUD_API_KEY=your-key translate -l
  1. Translate
GCLOUD_API_KEY=your-key translate -i "input-json-file" -o "output-json-file" -s source-language -t target-language

Below is a simple example which will translate the demo.json into Chinese and output to stdout:

GCLOUD_API_KEY=your-key translate -i "./testfiles/demo.json" -t zh

Example of translating yaml file:

GCLOUD_API_KEY=your-key translate -i "./testfiles/demo.yml" -t zh

Example of translating html file:

GCLOUD_API_KEY=your-key translate -i "./testfiles/demo.html" -t zh
Tips

If you do not want to specify google cloud api key everytime, you can export it to your ENV variable.

For Mac / Linux users, you can simply run export GCLOUD_API_KEY=your-key.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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