|
| 1 | +# lingo-docs |
| 2 | + |
| 3 | +A CLI tool to translate markdown documentation to multiple languages using [Lingo.dev](https://lingo.dev). |
| 4 | + |
| 5 | +Perfect for open-source maintainers who want to make their README and docs accessible to international users. |
| 6 | + |
| 7 | +## What it does |
| 8 | + |
| 9 | +```bash |
| 10 | +lingo-docs translate example/SAMPLE.md --langs es,ja |
| 11 | +``` |
| 12 | + |
| 13 | +``` |
| 14 | +╭───────────────────────────────── lingo-docs ─────────────────────────────────╮ |
| 15 | +│ SAMPLE.md → es, ja │ |
| 16 | +╰──────────────────────────── Powered by Lingo.dev ────────────────────────────╯ |
| 17 | +
|
| 18 | + Translation Results |
| 19 | +┏━━━━━━━━━━┳━━━━━━━━━━━━━━┳━━━━━━━━┓ |
| 20 | +┃ Language ┃ Output File ┃ Status ┃ |
| 21 | +┡━━━━━━━━━━╇━━━━━━━━━━━━━━╇━━━━━━━━┩ |
| 22 | +│ Español │ SAMPLE.es.md │ ✓ │ |
| 23 | +│ 日本語 │ SAMPLE.ja.md │ ✓ │ |
| 24 | +└──────────┴──────────────┴────────┘ |
| 25 | +``` |
| 26 | + |
| 27 | +**Features:** |
| 28 | +- Translates markdown files while preserving code blocks |
| 29 | +- Generates language selector badges for your README |
| 30 | +- Supports many languages (see table below) |
| 31 | +- Clean, focused CLI with beautiful output |
| 32 | + |
| 33 | +## Prerequisites |
| 34 | + |
| 35 | +- Python 3.11+ |
| 36 | +- [uv](https://docs.astral.sh/uv/) (recommended) or pip |
| 37 | +- Lingo.dev API key (free tier: 10,000 translated words/month) |
| 38 | + |
| 39 | +## Setup |
| 40 | + |
| 41 | +1. Clone and navigate to this directory: |
| 42 | + ```bash |
| 43 | + cd community/lingo-docs |
| 44 | + ``` |
| 45 | + |
| 46 | +2. Install dependencies: |
| 47 | + ```bash |
| 48 | + uv sync |
| 49 | + ``` |
| 50 | + Or with pip: |
| 51 | + ```bash |
| 52 | + pip install -e . |
| 53 | + ``` |
| 54 | + |
| 55 | +3. Get your Lingo.dev API key: |
| 56 | + - Sign up or log in at https://lingo.dev/en/auth?redirect=%2Fen%2Fapp |
| 57 | + - Navigate to Project Settings → API Keys |
| 58 | + - Click "Create API Key" and copy the generated key |
| 59 | + |
| 60 | +4. Set up environment: |
| 61 | + ```bash |
| 62 | + cp .env.example .env |
| 63 | + # Edit .env and add your API key |
| 64 | + ``` |
| 65 | + |
| 66 | +## Usage |
| 67 | + |
| 68 | +**Translate a file to multiple languages:** |
| 69 | +```bash |
| 70 | +lingo-docs translate README.md --langs es,ja,zh-CN |
| 71 | +``` |
| 72 | + |
| 73 | +**Specify source language (default: en):** |
| 74 | +```bash |
| 75 | +lingo-docs translate README.md --langs fr,de --source en |
| 76 | +``` |
| 77 | + |
| 78 | +**Add language selector badge to original file:** |
| 79 | +```bash |
| 80 | +lingo-docs translate README.md --langs es,ja --badge |
| 81 | +``` |
| 82 | + |
| 83 | +This adds a badge like: |
| 84 | +``` |
| 85 | +[English](README.md) | [Español](README.es.md) | [日本語](README.ja.md) |
| 86 | +``` |
| 87 | + |
| 88 | +**Generate badge without translating:** |
| 89 | +```bash |
| 90 | +lingo-docs badge example/SAMPLE.md --langs es,ja,zh-CN |
| 91 | +``` |
| 92 | + |
| 93 | +``` |
| 94 | +╭─────────────────────────────── Language Badge ───────────────────────────────╮ |
| 95 | +│ [English](SAMPLE.md) | [Español](SAMPLE.es.md) | [日本語](SAMPLE.ja.md) | │ |
| 96 | +│ [简体中文](SAMPLE.zh-CN.md) │ |
| 97 | +╰─────────────────────────────── For SAMPLE.md ────────────────────────────────╯ |
| 98 | +``` |
| 99 | + |
| 100 | +## Supported Languages |
| 101 | + |
| 102 | +| Code | Language | Code | Language | |
| 103 | +|------|----------|------|----------| |
| 104 | +| en | English | ja | 日本語 | |
| 105 | +| es | Español | ko | 한국어 | |
| 106 | +| fr | Français | zh-CN | 简体中文 | |
| 107 | +| de | Deutsch | zh-TW | 繁體中文 | |
| 108 | +| pt | Português | ar | العربية | |
| 109 | +| it | Italiano | hi | हिन्दी | |
| 110 | +| ru | Русский | nl | Nederlands | |
| 111 | + |
| 112 | +And more... |
| 113 | + |
| 114 | +## Lingo.dev Features Demonstrated |
| 115 | + |
| 116 | +- **[Python SDK](https://lingo.dev/en/sdk/python)**: Uses `LingoDotDevEngine` for AI-powered translation |
| 117 | +- **Async Translation**: Leverages async/await for efficient API calls |
| 118 | +- **Context Preservation**: Maintains markdown structure and code blocks during translation |
| 119 | + |
| 120 | +## Example |
| 121 | + |
| 122 | +See the `example/` directory for a sample README you can test with: |
| 123 | + |
| 124 | +```bash |
| 125 | +lingo-docs translate example/SAMPLE.md --langs es,ja --badge |
| 126 | +``` |
| 127 | + |
| 128 | +## License |
| 129 | + |
| 130 | +MIT |
0 commit comments