Local GPU translation Python library + MCP server — TranslateGemma via Ollama, 57 languages, zero cloud dependency
Project description
日本語 | 中文 | 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
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 client → localhost:11434
│ 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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file polyglot_gpu-1.0.3.tar.gz.
File metadata
- Download URL: polyglot_gpu-1.0.3.tar.gz
- Upload date:
- Size: 92.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
631d675fac13f460dc61ab5cff73c612bff8acdcfb3e3c5c947cdc4ef865d671
|
|
| MD5 |
d780d73da9f8ab435fbd8af7062351f1
|
|
| BLAKE2b-256 |
68c54a872119c694815249a9c4e08426541060c181ab0f6616f0b30d5b854745
|
Provenance
The following attestation bundles were made for polyglot_gpu-1.0.3.tar.gz:
Publisher:
publish.yml on mcp-tool-shop-org/py-polyglot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polyglot_gpu-1.0.3.tar.gz -
Subject digest:
631d675fac13f460dc61ab5cff73c612bff8acdcfb3e3c5c947cdc4ef865d671 - Sigstore transparency entry: 1050479829
- Sigstore integration time:
-
Permalink:
mcp-tool-shop-org/py-polyglot@e2320721fb556d16b471b9c47fa306d840f2dfb0 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/mcp-tool-shop-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e2320721fb556d16b471b9c47fa306d840f2dfb0 -
Trigger Event:
release
-
Statement type:
File details
Details for the file polyglot_gpu-1.0.3-py3-none-any.whl.
File metadata
- Download URL: polyglot_gpu-1.0.3-py3-none-any.whl
- Upload date:
- Size: 30.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
799063b8e61e1a9d84ec6caa83a31d3f0ba6b070e566756fec31e8110e8e5f9d
|
|
| MD5 |
88a700ebd72e8e835428594332c9294d
|
|
| BLAKE2b-256 |
28b9e7fa60db656278aabae18ea8c45cff80a60ecb20c73c767a526c9771a00d
|
Provenance
The following attestation bundles were made for polyglot_gpu-1.0.3-py3-none-any.whl:
Publisher:
publish.yml on mcp-tool-shop-org/py-polyglot
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
polyglot_gpu-1.0.3-py3-none-any.whl -
Subject digest:
799063b8e61e1a9d84ec6caa83a31d3f0ba6b070e566756fec31e8110e8e5f9d - Sigstore transparency entry: 1050479830
- Sigstore integration time:
-
Permalink:
mcp-tool-shop-org/py-polyglot@e2320721fb556d16b471b9c47fa306d840f2dfb0 -
Branch / Tag:
refs/tags/v1.0.3 - Owner: https://github.com/mcp-tool-shop-org
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@e2320721fb556d16b471b9c47fa306d840f2dfb0 -
Trigger Event:
release
-
Statement type: