ai-md-translator
v1.0.0
Published
A CLI tool to translate markdown files using AI models like DeepSeek or OpenAI
Maintainers
Readme
AI Markdown Translator (ai-md-translator)
A powerful TypeScript CLI tool to translate Markdown files using AI models like DeepSeek, OpenAI, etc.
Installation
npm install -g ai-md-translator
# Or run directly with npx
npx ai-md-translator <file> <lang> [model]Configuration
Create a amt.config.json in your project root:
{
"apiKey": "YOUR_API_KEY_HERE",
"modelType": "deepseek", // or "openai"
"modelName": "deepseek-chat", // optional specific model name
"apiBaseUrl": "https://api.deepseek.com/chat/completions", // optional custom URL
"inputDir": "./input",
"outputDir": "./output"
}You can also use .env file:
AMT_API_KEY=your_api_key_hereUsage
Translate a markdown file:
amt <filename> <target_language> [model_type]Examples:
Translate
hello.md(in configured input dir) to English using default model:amt hello.md enTranslate
docs/guide.mdto Chinese using DeepSeek explicitly:amt docs/guide.md zh deepseek
Output Behavior
- The tool will read from
inputDir(if configured) + filename. - It translates content while preserving Markdown formatting.
- Saves to
outputDir. - File Naming Rules:
- If
file.mddoes not exist in output -> saves asfile.md. - If
file.mdexists -> saves asfile-deepseek.md(appends model name). - If
file-deepseek.mdalso exists -> overwrites it.
- If
Supported Models
- DeepSeek: Set
modelType: "deepseek". - OpenAI: Set
modelType: "openai". - Custom: Configure
apiBaseUrlandmodelName.
License
ISC
