DevOps
LingoGeek: translating whole documents offline with CTranslate2 and a Python desktop app
Andrew Armstrong DEV Community
6 views
Hi DEV!
Pasting a document into a translation site works right up until the formatting matters. Then you get a wall of text back and rebuild the layout by hand. And if the document is a contract or a medical letter, you have just uploaded it to somebody else's server to save yourself ten minutes.
LingoGeek translates the file rather than the text:
.docx comes back as .docx, with headings, tables and lists intact
PDFs keep their layout
SRT and VTT subtitles keep their timings and cue numbers
Everything runs locally, nothing is uploaded, no per word charge
Why I built it
The translation quality problem is basically solved by open models now. The remaining problem is plumbing: getting the translated strings back into the document structure they came from without wrecking it. That is unglamorous work and it is the whole product.
Subtitles were the easiest, they are already segmented for you. Word documents were the fiddliest, because a single sentence can be split across several runs with different formatting, and you have to translate the sentence but reapply the runs.
Tech stack
Python, packaged as a desktop app
pywebview 5.3.2 for the shell, with fastapi 0.115.6 and uvicorn 0.32.1 behind it
ctranslate2 4.5.0 and sentencepiece 0.2.0 for inference
python-docx 1.1.2 and pypdf 5.1.0 for the document handling
pydantic 2.10.4 for the request models
Running a local FastAPI server behind a webview is an odd shape for a desktop app, but it meant the translation pipeline stayed a normal Python service I could test without a UI.
Honest caveat
The installer is not code signed yet, so SmartScreen may warn on first run. Complex PDF layouts are still the weak spot, multi column academic papers in particular.
Links
Site: https://techygeekshome.info/lingogeek/
Source: https://github.com/techygeekshome/LingoGeek
Video: https://youtu.be/hOF9UWpFFd8
Which language pairs do you actually need? That is what decides what I bundle next.
Read original: https://dev.to/techygeeks1/lingogeek-translating-whole-documents-offline-with-ctranslate2-and-a-python-desktop-app-22b5
← Previous
Why most 'AI fixes bugs automatically' demos don't survive contact with production
Next →
How I built an email-scanning SaaS audit engine with Next.js, Prisma and Neon
Related
Run YunCMS with Docker Compose: MySQL 8.4 Included
DevOps
3
DEV Community
What WhatsApp, Instagram and Telegram actually do to your photos
DevOps
4
DEV Community
The 2-Hour Bash Bug That Taught Me How Quoting Actually Works
DevOps
3
Dev.to (EN Zone)
Choosing free on-prem git server - Gitea is the winner!
DevOps
5
DEV Community
Comments0
No comments yet — be the first