Coco Polylang Autotranslate

WordPress Auto-Translation Plugin with N8N and AI

Introduction

Github source code: Link to github

The code is inside the repo for the whole website for kukulkite.com

I built a WordPress plugin that automatically translates Polylang posts using Large Language Models (it accepts only Deepseek so far). This side project allowed me to get familiar with N8N workflow automation while creating a practical solution for multilingual WordPress sites.

The plugin integrates seamlessly with WordPress admin panel and handles complex Gutenberg block content, not just plain text.

Technical Implementation

Architecture

  • WordPress Plugin as the interface layer
  • N8N as workflow orchestrator
  • LLM API (DeepSeek) for intelligent translation
  • WordPress REST API for content management
  • Webhooks for asynchronous communication

Workflow Process

  1. User Selection: Admin selects posts to translate from WordPress dashboard
  2. Webhook Trigger: Plugin sends translation parameters to N8N workflow
  3. Content Processing: N8N fetches post content via WordPress API
  4. AI Translation: Content gets processed by LLM with specific instructions
  5. Automatic Update: Translated content is saved back to WordPress

Technical Challenges

Gutenberg Block Handling

WordPress posts contain complex HTML, embedded JSON blocks, and metadata. The LLM needed specific instructions to translate content while preserving the entire block structure intact.

Content Chunking

Large posts are automatically divided into manageable chunks to work within LLM token limits while maintaining context and coherence.

Asynchronous Processing

Implemented bidirectional webhook communication allowing WordPress to wait for N8N workflow completion, handling variable processing times gracefully.

Error Management

Built comprehensive error handling across the entire pipeline, from API failures to connectivity issues, ensuring reliable user feedback.

Key Features

  • Complete automation from WordPress admin panel
  • Structure preservation for Gutenberg blocks and HTML
  • Multiple language support in single workflow
  • Flexible LLM providers through configurable API endpoints
  • Robust error handling with detailed status reporting

Technical Stack

json

{
  "backend": ["WordPress Plugin API", "N8N Workflows"],
  "apis": ["WordPress REST API", "LLM APIs"],  
  "authentication": ["WordPress Application Passwords"],
  "communication": ["Webhooks", "HTTP Requests"],
  "languages": ["PHP", "JavaScript"]
}

Results

The plugin successfully handles complex WordPress content translation while maintaining perfect formatting and structure. It scales efficiently for multiple posts and languages, providing a seamless user experience through the familiar WordPress interface.

This project demonstrates practical integration of modern AI tools with traditional CMS workflows, creating automated solutions for real-world content management challenges.