JsonTranslator
Simple Go module that helps with translating json files using Google Translator.
Install:
go get github.com/khaledalam/json-translator
Args:
-
[source json file path]
-
[interval in millisecond]
-
[Language_from]
-
[Language_to 1] [Language_to 2] [Language_to n..]
Flags:
- --output=files
Cli Examples:
→ input file test.json
:
{
"Home": "Home",
"Account": "Account"
}
↓ ↓ ↓ ↓
go run main.go $(pwd)/cli/test.json 5 en de
→ output file from ↑ command Translated_en_de.json
:
{
"Account": "Konto",
"Home": "Heim"
}
go run main.go $(pwd)/cli/test.json 5 en de it
→ output file from ↑ command Translated_en_de_it.json
:
{
"de": {
"Account": "Konto",
"Home": "Heim"
},
"it": {
"Account": "Account",
"Home": "Casa"
}
}
Testing
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