googletranslate

package module
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: MIT Imports: 9 Imported by: 0

README

Google Translate API in Golang

  • free
  • thread-safe
  • three endpoints
  • resilient to socket buffer errors

Install:

go get github.com/spywiree/googletranslate

Example usage:

package main

import (
    "fmt"
    gt "github.com/spywiree/googletranslate"
)

func main(){
    const text string = `Hello, World!`
    // you can use "auto" for source language
    // so, translator will detect language
    result, _ := gt.Translate(text, "en", "es")
    fmt.Println(result)
    // Output: "Hola, Mundo!"
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetMaxConnections

func SetMaxConnections(maxConcurrent int)

SetMaxConnections sets the maximum number of concurrent connections for Google Translate API. Specify -1 to disable the connection limit.

func Translate

func Translate(text, source, target string) (string, error)

Translate translates the given text from the source language to the target language using Google Translate API.

func TranslateApiV1

func TranslateApiV1(text, source, target string) (string, error)

TranslateApiV1 translates the given text from the source language to the target language using the translate.googleapis.com endpoint

func TranslateApiV2

func TranslateApiV2(text, source, target string) (string, error)

TranslateApiV2 translates the given text from the source language to the target language using translate.google.com/m endpoint.

func TranslateApiV3

func TranslateApiV3(text, source, target string) (string, error)

TranslateApiV3 translates the given text from the source language to the target language using clients5.google.com/translate_a/t endpoint.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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