日本語 | 中文 | Español | Français | हिन्दी | Italiano | Português (BR)
Local GPU translation Python library + MCP server — TranslateGemma via Ollama, 57 languages, zero cloud dependency.
Python port of polyglot-mcp. Use as a pip-installable library for your Python projects or as an MCP server for Claude Code, Claude Desktop, and other MCP clients.
Features
- 57 languages — TranslateGemma via Ollama, running 100% locally on your GPU
- Zero cloud dependency — no API keys, no internet required after model download
- Dual-use — Python library API + MCP server in one package
- Markdown-aware — preserves code blocks, tables, HTML, URLs, badges
- Smart caching — segment-level cache with fuzzy matching (translation memory)
- Software glossary — 12 built-in tech terms for accurate translations
- Auto-everything — auto-starts Ollama, auto-pulls models on first use
- GPU-safe — semaphore-controlled concurrency prevents VRAM overload
- Production-hardened — connection pooling, structured logging, 100 tests
Requirements
- Python >= 3.10
- Ollama installed locally
- GPU with sufficient VRAM for your chosen model:
translategemma:4b— 3.3 GB (fast, good quality)translategemma:12b— 8.1 GB (balanced, recommended)translategemma:27b— 17 GB (slow, best quality)
Install
pip install polyglot-gpu
Library Usage
import asyncio
from pypolyglot import translate, translate_markdown, translate_all
async def main():
# Simple translation
result = await translate("Hello world", "en", "ja")
print(result.translation) # こんにちは世界
# Markdown translation (preserves structure)
md = "## Features\n\nLocal GPU translation with **zero cloud dependency**."
result = await translate_markdown(md, "en", "fr")
print(result.markdown)
# Multi-language (7 languages at once)
result = await translate_all(md, source_lang="en")
for r in result.results:
print(f"{r.name}: {r.status}")
asyncio.run(main())
Options
from pypolyglot import translate, TranslateOptions, GlossaryEntry
# Custom model
result = await translate("Hello", "en", "ja",
TranslateOptions(model="translategemma:4b"))
# Custom glossary
result = await translate("Deploy the Widget", "en", "ja",
TranslateOptions(glossary=[
GlossaryEntry("Widget", {"ja": "ウィジェット"})
]))
# Streaming
result = await translate("Hello world", "en", "ja",
TranslateOptions(on_token=lambda t: print(t, end="")))
MCP Server Usage
Claude Code
{
"mcpServers": {
"polyglot-gpu": {
"command": "polyglot-gpu"
}
}
}
Or run directly:
python -m pypolyglot
MCP Tools
| Tool | Description |
|---|---|
translate_text |
Translate text between any of 57 languages |
translate_md |
Translate markdown while preserving structure |
translate_all_langs |
Translate into multiple languages at once |
list_languages |
List all 57 supported languages |
check_status |
Check Ollama + model availability |
Architecture
MCP Client (Claude Code, etc.)
│ MCP protocol (stdio)
▼
┌──────────────────┐
│ server.py │ 5 MCP tools (FastMCP)
├──────────────────┤
│ translate.py │ Chunking, batching, streaming
│ markdown.py │ Markdown segmentation
│ translate_all │ Multi-language orchestrator
│ semaphore.py │ GPU-safe concurrency
│ validate.py │ Output validation
├──────────────────┤
│ ollama.py │ httpx pooled client → Ollama
│ cache.py │ Segment cache + fuzzy memory
│ glossary.py │ Software term dictionary
│ languages.py │ 57 language definitions
│ polish.py │ Post-translation cleanup
│ errors.py │ Structured error class
└──────────────────┘
│ HTTP (httpx)
▼
Ollama + TranslateGemma (GPU)
Environment Variables
| Variable | Default | Description |
|---|---|---|
POLYGLOT_MODEL |
translategemma:12b |
Default Ollama model |
POLYGLOT_CONCURRENCY |
1 |
Max concurrent Ollama calls |
Security
- All translation runs locally — zero data leaves your machine
- No telemetry, no API keys, no cloud dependency
- See SECURITY.md for threat model
License
MIT
Built by MCP Tool Shop
Metadata
Release files for polyglot-gpu 1.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| polyglot_gpu-1.0.5.tar.gz | 114.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| polyglot_gpu-1.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 145.7 kB
Release files / polyglot_gpu-1.0.5.tar.gz
| Download URL | polyglot_gpu-1.0.5.tar.gz |
|---|---|
| Size | 114.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1f3849a59ac85531a8d2998dc163c03dade009e306b9cdbad657f96fc4ea8b94
|
|
BLAKE2b-256 checksum How to use checksums |
8ae418ddcd2ffba3f5c891d6b4108f18364629cc88ea0edb14335c70776cb999
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 26, 2026.
Transparency logRelease files / polyglot_gpu-1.0.5-py3-none-any.whl
| Download URL | polyglot_gpu-1.0.5-py3-none-any.whl |
|---|---|
| Size | 30.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3bf36c6c538d62feb942083ab4e96c8d866fb1483f3ac1b8806df4583514cd01
|
|
BLAKE2b-256 checksum How to use checksums |
51d9aa2c2464cb3a8663bf420a7504612413d83771bac7ebd95a49868a16ebe5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Mar 26, 2026.
Transparency log