https://github.com/digitalcrab/webtranslateit_go_client
WebTranslateIt.com GoLang Client
https://github.com/digitalcrab/webtranslateit_go_client
go golang transactions webtranslateit
Last synced: 3 months ago
JSON representation
WebTranslateIt.com GoLang Client
- Host: GitHub
- URL: https://github.com/digitalcrab/webtranslateit_go_client
- Owner: digitalcrab
- Archived: true
- Created: 2014-09-11T12:27:42.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-09-15T08:19:55.000Z (over 10 years ago)
- Last Synced: 2025-01-28T03:30:13.410Z (4 months ago)
- Topics: go, golang, transactions, webtranslateit
- Language: Go
- Size: 129 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# WebTranslateIt GoLang Client
[](http://travis-ci.org/fromYukki/webtranslateit_go_client)
This package is under active development. You can get more information about WebTranslateIt API using this link [https://webtranslateit.com/en/docs/api/](https://webtranslateit.com/en/docs/api/).
## Installation
To install this package, please, use default **go get** tool
go get github.com/fromYukki/webtranslateit_go_client
## Getting started
Authentication is made by so-called API tokens, and of course you need specify this one of the token to the `WebTranslateIt` structure.
```go
import wti_client "github.com/fromYukki/webtranslateit_go_client"func main() {
wti := wti_client.NewWebTranslateIt("YOUR_TOKEN")
project, err := wti.GetProject()
if err != nil {
panic(err)
}
}
```If you need to change API URL address or Token you can do it using next methods: `SetApiUrl` and `SetToken`.
### Project API
Project API section has only one method *Show Project*. You can read about it [here](https://webtranslateit.com/en/docs/api/project/).
#### Show Project
As shown in the example above, you can get the project and use it data as you wish. For more information, please, take a look on `Project` structure.
```go
import (
"fmt"
wti_client "github.com/fromYukki/webtranslateit_go_client"
)func main() {
wti := wti_client.NewWebTranslateIt("YOUR_TOKEN")
project, err := wti.GetProject()
if err != nil {
panic(err)
}
fmt.Printf("Project name: %q with %d files", project.Name, len(project.ProjectFiles))
}
```
### File APIOnly one method is implemented in the File API section. The rest you can find [here](https://webtranslateit.com/en/docs/api/file/).
#### Zip File
The easiest method to get all the translation files - is to download them in Zip archive.
```go
import (
"fmt"
wti_client "github.com/fromYukki/webtranslateit_go_client"
)func main() {
var (
err error
project wti_client.Project
zipFile wti_client.ProjectZipFile
data map[string][]byte
)
wti := wti_client.NewWebTranslateIt("YOUR_TOKEN")
if project, err = wti.GetProject(); err != nil {
panic(err)
}
if zipFile, err = project.ZipFile(); err != nil {
panic(err)
}
if data, err = zipFile.Extract(); err != nil {
panic(err)
}
for fileName, fileData := range data {
fmt.Printf("Extracted file %q with %d bytes length", fileName, len(fileData))
}
}
```