Go online translation package

Overview

Translate

Go online translation package

Install

go get github.com/nuveo/translate

Available Translator API's

  • Microsoft
  • or send us the next Translator API 😄

Usage

package main

import (
  "fmt"
  "log"
  "github.com/nuveo/translate"
)

func main() {
  // gettind your credentials here in: http://www.microsoft.com/translator/getstarted.aspx
  t := &microsoft.AuthRequest{"client_id", "client_secret"}
  // Generate a token valid for 10 minutes
  tokenResponse := microsoft.GetAccessToken(t)

  text := "one two three"
  from := "en"
  to := "pt"

  toTranslate := &microsoft.TextTranslate{
	Text: text, From: from, To: to, TokenResponse: tokenResponse,
  }

  // Get translate of text, return the word translated and error
  resp, err := microsoft.TranslateText(toTranslate)
  if err != nil {
	log.Println(err)
  }
  fmt.Println(resp) // um dois três

  texts := []string{"one two three", "the book on the table"}
  toTranslate.Texts = texts

  // or get translate of array of strings
  resps, err := microsoft.TranslateTexts(toTranslate)
  if err != nil {
	log.Println(err)
  }
  fmt.Println(resps) // [um dois três o livro em cima da mesa]

  // Detect the language of texts
  detect := []string{"mundo", "world", "monde"}
  toTranslate.Texts = detect

  respsD, err := microsoft.DetectText(toTranslate)
  if err != nil {
	log.Println(err)
  }
  fmt.Println(respsD, toTranslate.Texts) // [es en fr]
}

Support to cache with Redis

Now Translate make cache of words translated.

  // to activate cache
  toTranslate := &microsoft.TextTranslate{
	Text: text, From: from, To: to, TokenResponse: tokenResponse, Cache: true,
  }
You might also like...
This package provides a Go interface for the Typeform API.

typeform This package provides a Go interface for the Typeform API

A package for access aws service using AWS SDK for Golang

goaws 🚀 A package for access aws service using AWS SDK for Golang Advantage with goaws package Example for get user list IAM with AWS SDK for Golang

Package anko provides a golang SDK to the Anko Investor Forecasts gRPC service.

github.com/anglo-korean/anko-go-sdk Package anko provides a golang SDK to the Anko Investor Forecasts gRPC service. import "github.com/anglo-korean/an

An unofficial package in Golang to help developers implement ZATCA (Fatoora) QR code easily.

Zatca SDK GO An unofficial package in Golang to help developers to implement ZATCA (Fatoora) QR code easily which required for e-invoicing ✅ The hash

A SDK development package developed in go language and connected to dechain

Platform introduction Dechain go SDK is a SDK development package developed in go language and connected to dechain. This SDK can be provided to go cl

Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers

go-whatsapp Package rhymen/go-whatsapp implements the WhatsApp Web API to provide a clean interface for developers. Big thanks to all contributors of

Go package to work with temperatures

tempconv This is an exercise of the book The Go Programming Language, by Alan A.

A simple package in Golang containing helpers for functional programming

go-functools Golang package containing functools using Go generics functools is

A Package Searching and Installation tool for Go Projects
A Package Searching and Installation tool for Go Projects

psearch A Package Searching and Installation tool for Go Projects. Installation

Comments
  • Add approach to mock requests to microsoft api

    Add approach to mock requests to microsoft api

    This change in the package code microsoft allows you to fake requests to be used in testing, but for now, is in trouble.

    2015/07/22 08:45:12 Post https://datamarket.accesscontrol.windows.net/v2/OAuth2-13: http: error connecting to proxy https://127.0.0.1:61522: dial tcp 127.0.0.1:61522:
     connection refused
    --- FAIL: TestGetToken (0.01s)
    panic: runtime error: invalid memory address or nil pointer dereference [recovered]
            panic: runtime error: invalid memory address or nil pointer dereference
    [signal 0xb code=0x1 addr=0x0 pc=0x61d05]
    
    
    opened by marioidival 0
Owner
nuveo
Artificial Intelligence within reach
nuveo
A simple self-hostable Machine Translation service, powered by spaGO

A simple self-hostable Machine Translation service, powered by spaGO

null 105 Nov 9, 2022
Python library for the DeepL language translation API.

The DeepL API is a language translation API that allows other computer programs to send texts and documents to DeepL's servers and receive high-quality translations.

DeepL 539 Jan 6, 2023
Elastos.ELA.Rosetta.API - How to write a Rosetta server and use either the Client package or Fetcher package to communicate

Examples This folder demonstrates how to write a Rosetta server and how to use e

Elastos Foundation 3 Jan 17, 2022
Go package providing opinionated tools and methods for working with the `aws-sdk-go/service/cloudfront` package.

go-aws-cloudfront Go package providing opinionated tools and methods for working with the aws-sdk-go/service/cloudfront package. Documentation Tools $

aaronland 0 Feb 2, 2022
Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://developer.github.com/v4/).

githubv4 Package githubv4 is a client library for accessing GitHub GraphQL API v4 (https://docs.github.com/en/graphql). If you're looking for a client

null 956 Dec 26, 2022
A simple Go package to fetch lyrics from Wikia

golyrics This is a simple scrapper package to fetch lyrics data from the Wikia website. Installation go get github.com/mamal72/golyrics Usage package

Mohamad Jahani 40 Dec 24, 2022
A golang package to communicate with HipChat over XMPP

hipchat This is a abstraction in golang to Hipchat's implementation of XMPP. It communicates over TLS and requires zero knowledge of XML or the XMPP p

Dane Harrigan 110 Jan 3, 2023
Package captcha is a middleware that provides captcha service for Flamego

auth Package captcha is a middleware that provides captcha service for Flamego. Installation The minimum requirement of Go is 1.16. go get github.com/

Flamego 13 Dec 14, 2022
Utilcanvas is a package which provides some utilities to interface with the Canvas LMS Api.

Utilcanvas Utilcanvas is a package which provides some utilities to interface with the Canvas LMS Api. Example usage c := utilcanvas.NewClient("https:

Martín Zamorano 1 Dec 21, 2022
Metrics package helps to create ydb-go-sdk traces with monitoring internal state of driver

metrics metrics package helps to create ydb-go-sdk traces with monitoring internal state of driver Usage import ( "fmt" "sync/mutex" "time

YDB Platform 3 Jan 7, 2023