https://github.com/cppcoffee/translator
A lightweight Chinese-English bidirectional translation command-line tool
https://github.com/cppcoffee/translator
Last synced: 6 days ago
JSON representation
A lightweight Chinese-English bidirectional translation command-line tool
- Host: GitHub
- URL: https://github.com/cppcoffee/translator
- Owner: cppcoffee
- Created: 2026-05-25T02:42:30.000Z (15 days ago)
- Default Branch: main
- Last Pushed: 2026-05-25T03:32:04.000Z (15 days ago)
- Last Synced: 2026-05-25T04:27:47.720Z (15 days ago)
- Language: Python
- Size: 4.88 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Translator
A Chinese-English translation tool using OpenAI-compatible APIs.
## Features
- Chinese → English translation
- English → Chinese translation
## Requirements
No external dependencies required. Uses Python standard library only.
Python 3.6+ is required.
## Installation
```bash
git clone
cd translator
```
## Configuration
Edit `.env` file with your API settings. Supports OpenAI-compatible APIs:
**OpenAI:**
```env
API_KEY=sk-xxx
BASE_URL=https://api.openai.com/v1
MODEL=gpt-4o
```
**DeepSeek:**
```env
API_KEY=sk-xxx
BASE_URL=https://api.deepseek.com
MODEL=deepseek-chat
```
**Other compatible providers** (Anthropic, local LLMs, etc.) work similarly.
## Usage
Run the script:
```bash
python translator.py
```
Or create a symlink for global access:
```bash
sudo ln -s /path/to/translator/translator.py /usr/local/bin/tt
```
Then use directly:
```bash
tt
```
Follow the prompts to select translation direction and input your text.
## Example
```
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.
```
## License
MIT