Provides tools for analyzing, validating, and updating Django gettext .po translation files with intelligent preservation of Python format strings, Django template variables and tags, HTML tags, URLs, and JavaScript code.
PO Translation MCP Server
MCP server for translating Django gettext .po files with AI assistance, featuring intelligent preservation of variables, HTML tags, URLs, and JavaScript code.
✨ Features
✅ analyze_po_file: Analyze .po files with statistics and line numbers
✅ validate_and_update_po_file: Combined validation + update in one operation
🤖 Claude-Powered Translation: Leverages Claude's native translation capabilities
🔄 Variable Preservation: Python format strings, Django templates
🏷️ HTML Preservation: Keep all HTML tags intact
🌐 URL Preservation: URLs never get translated
💻 JavaScript Preservation: Smart code detection (not natural language patterns)
📍 Line Number Tracking: AI can locate entries precisely in source files
🚀 Installation
📖 Usage with Claude Code
Add to your Claude Code MCP settings:
🔧 MCP Tools
1. analyze_po_file
Analyze a .po file and get translation statistics with line numbers:
Output:
2. validate_and_update_po_file
Combined validation and update in one operation - validates translations and automatically updates the PO file if valid:
Output:
Options:
dry_run: true- Preview changes without writingforce_update: true- Update even if some translations are invalidstrict_mode: true- Treat warnings as errors
🔄 Complete Translation Workflow
With Claude Code
Why No translate_entries Tool?
This MCP server leverages Claude's native translation capabilities. Instead of implementing a separate translation API:
analyze_po_file finds entries that need translation
Claude translates them directly using its language understanding
validate_and_update_po_file ensures quality (variables, HTML, URLs preserved) AND updates the file
This approach is:
✅ More accurate: Claude understands context better than machine translation
✅ Simpler: No API keys or external services needed
✅ Flexible: Claude can handle edge cases and ask for clarification
✅ Cost-effective: No separate translation API costs
✅ Efficient: Combined validation + update in one step
🧪 Testing
Test Output:
🛡️ Pattern Preservation
The server preserves 12+ pattern types:
Python Variables:
%(name)s- Python old-style format{0},{variable}- Python format strings{{ variable }}- Django template variables
Django Tags:
{% tag %}- Django template tags{# comment #}- Django comments
HTML Tags:
<tag>,</tag>- Opening/closing tags<tag attr="value">- Tags with attributes
URLs:
https://example.com- Full URLs with protocolwww.example.com- URLs without protocol/path/to/resource- Relative URLs
JavaScript Code (Smart Detection):
console.log("text")- String parametersmodule.method()- Dot notation callsgetData('value')- Quote-containing parameters❌ NOT
Reservation (No Payment)- Natural language (false positives avoided)
📁 Project Structure
💻 Development
📦 Dependencies
✅ Implementation Status
Completed Tools:
✅ analyze_po_file (with line number tracking)
✅ validate_and_update_po_file (combined validation + update)
Key Improvements:
✅ Fixed JavaScript pattern detection (no false positives on natural language)
✅ Simplified API: 2 tools instead of 4
✅ One-step workflow: validate + update in single operation
Test Status:
✅ Build: No errors
✅ analyze_po_file: Tested with 2878 entries
✅ Pattern detection: Smart JS detection working
✅ Line number tracking: Accurate line mapping
Ready for: Production use with Claude Code
📊 Statistics
Total Files: 8 TypeScript source files
MCP Tools: 2 (analyze + validate_and_update)
Pattern Types: 12+ preserved (smart JS detection)
Build Status: ✅ Success
🙏 License
MIT
This server cannot be installed