https://github.com/khaledalam/json-translator
Simple Go module that helps with translating json files using Google Translator.
https://github.com/khaledalam/json-translator
go golang google googletranslate json json-schema translate translation
Last synced: about 1 month ago
JSON representation
Simple Go module that helps with translating json files using Google Translator.
- Host: GitHub
- URL: https://github.com/khaledalam/json-translator
- Owner: khaledalam
- License: mit
- Created: 2023-06-11T10:54:08.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2023-06-13T04:41:03.000Z (about 3 years ago)
- Last Synced: 2025-02-10T07:27:42.221Z (over 1 year ago)
- Topics: go, golang, google, googletranslate, json, json-schema, translate, translation
- Language: Go
- Homepage: https://pkg.go.dev/github.com/khaledalam/json-translator
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## JsonTranslator
#### Simple Go module that helps with translating json files using Google Translator.
[](https://goreportcard.com/report/github.com/khaledalam/json-translator)
[](https://pkg.go.dev/github.com/khaledalam/json-translator?status)

### Install:
```shell
go get github.com/khaledalam/json-translator
```
### Args:
- [x] `[source json file path]`
- [x] `[interval in millisecond]`
- [x] `[Language_from]`
- [x] `[Language_to 1] [Language_to 2] [Language_to n..]`
### Flags:
- [ ] --output=files
---
### Cli Examples:
→ input file `test.json`:
```json
{
"Home": "Home",
"Account": "Account"
}
```
↓ ↓ ↓ ↓
```bash
go run main.go $(pwd)/cli/test.json 5 en de
```
→ output file from ↑ command `Translated_en_de.json`:
```json
{
"Account": "Konto",
"Home": "Heim"
}
```
---
```bash
go run main.go $(pwd)/cli/test.json 5 en de it
```
→ output file from ↑ command `Translated_en_de_it.json`:
```json
{
"de": {
"Account": "Konto",
"Home": "Heim"
},
"it": {
"Account": "Account",
"Home": "Casa"
}
}
```
---
### Testing
```shell
make test
```
```
2023/06/13 04:31:32 [en => de] Done: 1 / 2
2023/06/13 04:31:33 [en => de] Done: 2 / 2
2023/06/13 04:31:33 -----
2023/06/13 04:31:33 [en => de] Done: 1 / 2
2023/06/13 04:31:33 [en => de] Done: 2 / 2
2023/06/13 04:31:33 [en => it] Done: 1 / 2
2023/06/13 04:31:33 [en => it] Done: 2 / 2
2023/06/13 04:31:33 -----
2023/06/13 04:31:33 Error: when reading json file. open invalid/json/file/path/a.json: no such file or directory
2023/06/13 04:31:33 Error: when reading json file. [multi]
2023/06/13 04:31:33 -----
PASS
github.com/khaledalam/json-translator coverage: 70.8% of statements
ok github.com/khaledalam/json-translator 0.682s
```