smirkcat / go-google-translate

A go library to translate unlimited using Google Translator by parsing HTML.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

go-google-translate

Do you want to use google translator API? API is not free anymore. But you can translate 1000 words per day free. And then may be this project can help you to translate unlimited text from one language to another using Google Translator.

Overview

go-google-translate provides a go package to translate using Google Translator by parsing HTML. This library can be used to translate from any language to any other.

In addition this library provides a cli to translate text via console.

Installation

$ go get -u -v github.com/smirkcat/go-google-translate/...

Usage

package main

import (
	"fmt"
	"log"

	trans "github.com/smirkcat/go-google-translate/pkg"
)

func main() {
	// request struct
	req := &trans.TranslateRequest{
		SourceLang: "bn",
		TargetLang: "en",
		Text:       "আমি বাংলায় গান গাই",
	}
	// translate
	translated, err := trans.Translate(req)
	if err != nil {
		log.Fatalln(err)
	}
	fmt.Println(translated) // I sing in Bangla
}

CLI

Command line interface to translate text using command line.

Install

$ go get -u -v github.com/aerokite/go-google-translate/cmd/gopret
$ go install github.com/aerokite/go-google-translate/cmd/gopret

Usages

$ gopret translate --sl bn --tl en --text "আমি বাংলায় গান গাই"
I sing in Bangla

Acknowledgement

Arnaud Aliès for mtranslate in python.

License

Copyright (c) 2017 Mir Shahriar

Licensed under MIT Licence.

About

A go library to translate unlimited using Google Translator by parsing HTML.

License:MIT License


Languages

Language:Go 87.2%Language:Python 12.8%