A CLI tool that translates text between languages using the Google Cloud Translation API.
- based on the $SHELL add alias to ~/.zshrc or ~/.bashrc
- Go to Google Cloud Console
- Create a project (or use an existing one)
- Enable the Cloud Translation API
- Create an API key under APIs & Services > Credentials
export GOOGLE_TRANSLATION_API_KEY="YOUR_API_KEY"mkdir -p ~/.console-translate
echo '{"default_pair": "en-ru"}' > ~/.console-translate/config.jsongo build -o console-translate .
# optionally move to PATH:
mv console-translate /usr/local/bin/# Translate with explicit language pair
console-translate -p en-ru hello world
# hello world -> привет мир
# Translate using default pair from config (auto-detects direction)
console-translate hello
# hello -> привет
console-translate привет
# привет -> hello
# Use a custom config file
console-translate -c /path/to/config.json hello
# Show version
console-translate --version| Flag | Short | Description |
|---|---|---|
--pair |
-p |
Language pair (e.g. en-ru) |
--config |
-c |
Config file path (default: ~/.console-translate/config.json) |
--version |
-v |
Show version |
--help |
-h |
Show help |
The config file is JSON with two fields:
| Field | Description |
|---|---|
default_pair |
Default language pair used when -p is not specified |
The API key is read from the GOOGLE_TRANSLATION_API_KEY environment variable.