Skip to content

Commit ee5267c

Browse files
feat: add lingo-docs - markdown documentation translator (#1899)
* feat(community): add lingo-docs - markdown documentation translator Python CLI that translates markdown documentation to multiple languages using the Lingo.dev Python SDK. Preserves code blocks during translation and generates language selector badges. * fix: address CodeRabbit review comments for lingo-docs --------- Co-authored-by: Sumit Saurabh <62152915+sumitsaurabh927@users.noreply.github.com>
1 parent fa69822 commit ee5267c

File tree

8 files changed

+483
-0
lines changed

8 files changed

+483
-0
lines changed

.changeset/fast-schools-smile.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
---
3+
4+
Add lingo-docs: a Python CLI tool to translate markdown documentation to multiple languages using Lingo.dev SDK.

community/lingo-docs/.env.example

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Get your API key from https://lingo.dev (free tier: 10,000 tokens/month)
2+
# 1. Sign up at https://lingo.dev/en/auth
3+
# 2. Go to Projects → API key → Copy
4+
LINGODOTDEV_API_KEY=your_api_key_here

community/lingo-docs/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.env
2+
.venv/
3+
__pycache__/
4+
*.egg-info/
5+
*.pyc

community/lingo-docs/README.md

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
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
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# My Awesome Project
2+
3+
A simple utility to make developers happy.
4+
5+
## Installation
6+
7+
```bash
8+
npm install awesome-project
9+
```
10+
11+
## Usage
12+
13+
```javascript
14+
import { awesome } from 'awesome-project';
15+
16+
const result = awesome('Hello World');
17+
console.log(result);
18+
```
19+
20+
## Features
21+
22+
- Fast and lightweight
23+
- Easy to use
24+
- Well documented
25+
26+
## Contributing
27+
28+
Pull requests are welcome! Please read our contributing guidelines first.
29+
30+
## License
31+
32+
MIT License - feel free to use this in your projects.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""lingo-docs: Translate markdown documentation using Lingo.dev"""
2+
3+
__version__ = "0.1.0"

0 commit comments

Comments
 (0)