A CLI and Python library for translating and improving text using Google Gemini models.
- Features
- Installation
- Building a Wheel
- Dependencies
- Environment Setup
- Usage
- Model Information
- Troubleshooting & FAQ
- License
- Contact
- Translate and improve text from any language to professional English
- Command-line interface (CLI) for easy translation from stdin to stdout
- Python API for integration in your own scripts
- Supports Google Gemini models for both text and image generation
- List available Gemini models from the CLI
- Clipboard translation scripts for Linux and Windows
- Clone the repository:
git clone <your-repo-url> cd translAItor
- Install dependencies:
Make sure you are using Python 3.12 or 3.13 (as specified in
pyproject.toml).Or, for development:pip install .pip install -e .
To build a wheel distribution:
pip install build
python -m build --wheelThe wheel file will be created in the dist/ directory.
- google-genai==1.21.1
- python-dotenv==1.0.1
- Pillow==11.1.0
- click==8.1.7
You must set your Google Gemini API key in your environment. You can do this by creating a .env file in the project root:
GEMINI_API_KEY=your_api_key_here
Or export it directly:
export GEMINI_API_KEY=your_api_key_hereAfter installation, you can launch the graphical clipboard translator with:
python -m translaitor.guior, if you have an entry point installed:
translaitor-guiFeatures:
- Input and output text areas for translation
- Translate Text and Copy Output to Clipboard buttons are side by side and only as wide as their labels
- The Copy Output to Clipboard button is automatically disabled if the output area is empty
- Status bar shows input/output character counts, dry run mode, and API key status
- Dry run mode copies input to output without calling the API
- Gemini API key status is shown at the bottom
After installation, you can use the CLI directly:
Translate text from standard input and print the result to standard output:
translaitor translateYou can also redirect files:
translaitor translate input.txt output.txtList available Gemini models:
translaitor list-modelsecho "Ciao, come stai?" | translaitor translate
# Output: How are you?- Linux: Use
translate_clipboard.shto translate clipboard contents and copy the result back. Requiresxclipand notification support. - Windows: Use
translate_clipboard.ps1(requires the BurntToast module for notifications) for the same functionality. See script comments for details.
You can use the translation functionality in your own scripts:
from translaitor.ai_client import translate_call, TRANSLATING_PROMPT
prompt = "Ciao, come stai?"
result = translate_call(TRANSLATING_PROMPT.format(to_translate=prompt))
print(result)from translaitor.ai_client import list_gemini_models
models = list_gemini_models()
for name, desc in models:
print(f"{name}: {desc}")You can view a list of available Gemini models using the CLI (translaitor list-models) or by checking the models.txt file in this repository for descriptions and details.
Q: I get an error about missing the API key.
- Make sure you have set
GEMINI_API_KEYin your.envfile or environment.
Q: The CLI command is not found after install.
- Make sure your Python environment's
bin/Scriptsdirectory is in your PATH. - Try
pip install -e .from the project root.
Q: How do I get notifications on Windows?
- The PowerShell script uses the BurntToast module. Install it with:
Install-Module -Name BurntToast -Force
Q: How do I update the list of models?
- Run
translaitor list-modelsto fetch the latest from the Gemini API.
MIT License
For questions, suggestions, or support, please open an issue on the repository or contact the maintainer at [your-email@example.com].