60 lines
1.6 KiB
Markdown
60 lines
1.6 KiB
Markdown
# d10n - Content Translation CLI Tool
|
|
|
|
`d10n` is a CLI tool for translating text content in files or directories using LLM models.
|
|
|
|
## Configuration
|
|
|
|
Create a configuration file at `~/.config/d10n.yaml` with the following format:
|
|
|
|
```yaml
|
|
api_base: "https://api.openai.com" # OpenAI-compatible API base URL
|
|
api_key: "your-api-key" # API key for the service
|
|
model: "gpt-4o" # Model to use for translation
|
|
system_prompt: "Custom prompt" # Optional: Custom system prompt
|
|
```
|
|
|
|
You can use the following variables in your system prompt:
|
|
- `$SOURCE_LANG`: Will be replaced with the source language code
|
|
- `$TARGET_LANG`: Will be replaced with the target language code
|
|
|
|
## Usage
|
|
|
|
```
|
|
d10n <source_path> [options]
|
|
```
|
|
|
|
### Options
|
|
|
|
- `-target <path>`: Target path for translated content (default: `<source_path>_l10n[.extension]`)
|
|
- `-source-lang <code>`: Source language code (required)
|
|
- `-target-lang <code>`: Target language code (required)
|
|
- `-model <model>`: Model to use for translation (overrides config)
|
|
- `-api-key <key>`: API key (overrides config)
|
|
- `-api-base <url>`: API base URL (overrides config)
|
|
- `-system-prompt <prompt>`: System prompt (overrides config)
|
|
- `-format <ext>`: File format to process (e.g., `md`, `txt`)
|
|
|
|
### Examples
|
|
|
|
Translate a single file from English to Spanish:
|
|
```
|
|
d10n document.md -target-lang es
|
|
```
|
|
|
|
Translate a directory of Markdown files to Chinese:
|
|
```
|
|
d10n ./documents -target-lang zh -format md
|
|
```
|
|
|
|
Specify source language explicitly:
|
|
```
|
|
d10n article.txt -source-lang fr -target-lang en
|
|
```
|
|
|
|
## Building from Source
|
|
|
|
```
|
|
go build -o d10n
|
|
```
|
|
|
|
Then move the binary to a location in your PATH.
|