Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

translate

Golang translation library that supports several free providers.

Current supported provider list:

Installation

go get github.com/maxwolf8852/translate

Usage

You can use this library with one or several providers (e.g. if the first one fails, the library will request translation from from the next one, and so on).

One-provider

client, err := translate.New(translate.WithProvider(google.New()))
if err != nil {
    return err
}
out, err := client.Translate(t.Context(), translate.EN, translate.FR, "Hello world!")
if err != nil {
    return err
}
fmt.Println(out)

Multiple-providers (with error skip)

This example skips all errors until the last one and prints the last (successful or not) output.

client, err := translate.New(translate.WithSkipErrors(),
			translate.WithProvider(google.New()),
			translate.WithProvider(mymemory.New()), ...)
if err != nil {
    return err
}
out, err := client.Translate(context.TODO(), translate.EN, translate.FR, "Hello world!")
if err != nil {
    return err
}
fmt.Println(out)

About

Golang translation library

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages