A Chinese-English translation tool using OpenAI-compatible APIs.
- Chinese → English translation
- English → Chinese translation
No external dependencies required. Uses Python standard library only.
Python 3.6+ is required.
git clone <repo-url>
cd translatorEdit .env file with your API settings. Supports OpenAI-compatible APIs:
OpenAI:
API_KEY=sk-xxx
BASE_URL=https://api.openai.com/v1
MODEL=gpt-4oDeepSeek:
API_KEY=sk-xxx
BASE_URL=https://api.deepseek.com
MODEL=deepseek-chatOther compatible providers (Anthropic, local LLMs, etc.) work similarly.
Run the script:
python translator.pyOr create a symlink for global access:
sudo ln -s /path/to/translator/translator.py /usr/local/bin/ttThen use directly:
ttFollow the prompts to select translation direction and input your text.
Select translation direction:
1. Chinese -> English
2. English -> Chinese
Enter option (1/2, default: 1): 1
Enter Chinese text (Ctrl+C or empty to exit):
> 你好,世界
Hello, world
> 今天天气怎么样
How's the weather today
>
Exit.
MIT