Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/huhx/go_translator
Translation tools using Go
https://github.com/huhx/go_translator
go translation
Last synced: about 2 months ago
JSON representation
Translation tools using Go
- Host: GitHub
- URL: https://github.com/huhx/go_translator
- Owner: huhx
- License: apache-2.0
- Created: 2024-04-17T15:47:40.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-06-07T13:56:49.000Z (7 months ago)
- Last Synced: 2024-06-07T15:26:07.258Z (7 months ago)
- Topics: go, translation
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
A command line tool that translate chinese to english and vice versa,
it also provides the feature of querying the translation history.> Right now, it only supports the English and Chinese languages.
## Background
When I want to translate words between chinese and english,
using the Google translation web page I need to choose the source and target language. It is less convenient to me. So I
decide to develop a command line tool
that simplify the translation work since it can identify the language automatically.## Implementation
* `cobra`: the core of the command line
* `viper`: store the translation api key and secret
* `http`: use to call translation api## Features
* Translation:
```shell
trans "I love coding" # 我喜欢编码
trans 我喜欢游泳 # I like swimming
```* History record
```shell
trans -l# Query| Result|CreateTime
# ----| ---|-------
# Chinese people are very intelligent| 中国人非常聪明|2024-04-18 17:02:10
# 我们的爱从未消失| Our love never disappears|2024-04-18 17:04:12
# make the world much better| 让世界变得更美好|2024-04-18 17:04:30
```* Clean up history record
```shell
trans -c # successfully cleared
```## Deploy
### prepare the viper configuration file: ~/.go_translator.yaml
```yaml
appId: "{baidu_app_id}"
appSecret: "{baidu_app_secret}"
fileName: "go_translator_record.csv
```
https://fanyi-api.baidu.com/manage/developer### build the exec command
```shell
go build -o trans main.go
go install trans# or
make deploy
```