generate_translator 1.0.9
generate_translator: ^1.0.9 copied to clipboard
A CLI tool to convert plain text files into translated JSON files using Google Translate.
🧩 Generate Translator #
Generate Translator is a command-line tool (CLI) that converts plain .text files into JSON or ARB multilingual files using Google Translate API.
🚀 Installation #
Install globally via pub.dev:
dart pub global activate generate_translator
🛠️ Usage #
- Translate a single language:
generate_translator vi ./assets/input.text ./assets/vi.json
- Translate multiple languages using a shell script:
items=("vi" "en" "zh-tw" "zh-cn")
for item in "${items[@]}"
do
generate_translator $item ../assets/input.text ./$item.arb
done
📁 The input.text file should contain the strings to translate, one per line.
🍎 IOS / macOS / Linux Setup #
✅ Make sure the terminal can find generate_translator globally: Add the following line to your ~/.zshrc, ~/.bashrc, or ~/.bash_profile:
export PATH="$PATH":"$HOME/.pub-cache/bin"
Then reload your terminal config:
source ~/.zshrc # or ~/.bashrc depending on your shell
Sample input.text #
Hello
Welcome
Logout
After running the script, it will generate translated files like vi.json, en.json, zh-tw.arb, etc.