Skip to content

cppcoffee/translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

git clone <repo-url>
cd translator

Configuration

Edit .env file with your API settings. Supports OpenAI-compatible APIs:

OpenAI:

API_KEY=sk-xxx
BASE_URL=https://api.openai.com/v1
MODEL=gpt-4o

DeepSeek:

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:

python translator.py

Or create a symlink for global access:

sudo ln -s /path/to/translator/translator.py /usr/local/bin/tt

Then use directly:

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

About

A lightweight Chinese-English bidirectional translation command-line tool

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages