Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mind1949/googletrans
G文⚡️: Concurrency-safe, Free and Unlimited google translate api for Golang. 🔥免费、无限、并发安全的谷歌翻译包
https://github.com/mind1949/googletrans
concurrency-safe detect-language go go-library go-package golang google-translate google-translate-api googletrans language translator
Last synced: about 2 months ago
JSON representation
G文⚡️: Concurrency-safe, Free and Unlimited google translate api for Golang. 🔥免费、无限、并发安全的谷歌翻译包
- Host: GitHub
- URL: https://github.com/mind1949/googletrans
- Owner: mind1949
- License: mit
- Archived: true
- Created: 2020-08-18T12:52:46.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-11-19T00:59:55.000Z (about 4 years ago)
- Last Synced: 2024-08-03T23:23:38.583Z (5 months ago)
- Topics: concurrency-safe, detect-language, go, go-library, go-package, golang, google-translate, google-translate-api, googletrans, language, translator
- Language: Go
- Homepage:
- Size: 47.9 KB
- Stars: 109
- Watchers: 4
- Forks: 22
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-golang-repositories - googletrans - safe, Free and Unlimited google translate api for Golang. �ス鄕ゑソス�壽匕�ス錡シ�ス�ス贒個錡サ蜒趣ソス﨣ォ�ス�ス蜃ス�ス髱夂臓�ス陜ァ鬢会ソス�ス�ス (Repositories)
README
# Googletrans
[![language](https://img.shields.io/badge/language-Golang-blue)](https://golang.org/)
[![Documentation](https://godoc.org/github.com/mind1949/googletrans?status.svg)](https://godoc.org/github.com/mind1949/googletrans)
[![Go Report Card](https://goreportcard.com/badge/github.com/mind1949/googletrans)](https://goreportcard.com/report/github.com/mind1949/googletrans)G文⚡️: Concurrency-safe, free and unlimited golang library that implemented Google Translate API.
Inspired by [py-googletrans](https://github.com/ssut/py-googletrans).
# Features
* Out of the box
* Auto language detection
* Customizable service URL
# Installation```
go get -u github.com/mind1949/googletrans
```# Usage
## Detect language
```golang
package mainimport (
"fmt""github.com/mind1949/googletrans"
)func main() {
detected, err := googletrans.Detect("hello googletrans")
if err != nil {
panic(err)
}format := "language: %q, confidence: %0.2f\n"
fmt.Printf(format, detected.Lang, detected.Confidence)
}// Output:
// language: "en", confidence: 1.00
```## Translate
```golang
package mainimport (
"fmt""github.com/mind1949/googletrans"
"golang.org/x/text/language"
)func main() {
params := googletrans.TranslateParams{
Src: "auto",
Dest: language.SimplifiedChinese.String(),
Text: "Go is an open source programming language that makes it easy to build simple, reliable, and efficient software. ",
}
translated, err := googletrans.Translate(params)
if err != nil {
panic(err)
}
fmt.Printf("text: %q \npronunciation: %q", translated.Text, translated.Pronunciation)
}// Output:
// text: "Go是一种开放源代码编程语言,可轻松构建简单,可靠且高效的软件。"
// pronunciation: "Go shì yī zhǒng kāifàng yuán dàimǎ biānchéng yǔyán, kě qīngsōng gòujiàn jiǎndān, kěkào qiě gāoxiào de ruǎnjiàn."
```## Customize service URLs
```golang
package mainimport "github.com/mind1949/googletrans"
func main() {
serviceURLs := []string{
"https://translate.google.com/",
"https://translate.google.pl/"}
googletrans.Append(serviceURLs...)
}
```