Recently, with various AI models being rolled out on a large scale, the cost of tokens has become quite low. This has led me to consider transforming my blog to support a multilingual version. I mainly write articles in Chinese, and I plan to have the machine automatically translate them into other languages (for now, I’m only focusing on adding an English version).
Since this is primarily a site for documenting daily tech updates, I prefer not to add any paid plugins and will try to use free plugins to achieve this. This article documents the related work.
Polylang Installation
Search for the Polylang plugin in the WordPress plugin repository, then install and configure it (the free version is sufficient). Be sure to select the default language corresponding to your existing articles during the setup to avoid a blank homepage after installation.
If you choose the correct language, there will be a pentagon star indicator next to it.
n8n Workflow
During the debugging phase, the process is relatively straightforward. You can refer to the content on this site and import the n8n workflow file: https://n8n.akashio.com/29557cabc67e42bcbc29effe1bdc8cd0, and try experimenting with some of the existing articles.
I’ve chosen the gpt-4o-mini model for translating articles and gpt-4 for translating titles, but you can adjust the workflow and model based on your needs.
Full Automation
After completing the two steps mentioned above, you should be able to automatically translate existing articles into another language via manual trigger. However, aside from the limitation that the free version of Polylang cannot map the relationship between multilingual versions through the API, the remaining challenge is how to automatically translate new articles into English.
This issue arises from the following reasons:
- The free version of the Polylang plugin cannot establish a relationship between articles in different languages through the API.
- Manually triggering article translations can be cumbersome and requires logging into multiple systems.
- For the n8n workflow, there’s no way to track which articles have already been translated, leading to potential omissions or duplicates.
Given the current situation, we generally have two solutions: one is to log our work in a database, and the other is to use webhooks. The downside of the database-based approach is that it introduces a new, heavier component, while the webhook approach has the drawback that WordPress doesn’t natively support it. Ultimately, I chose to use webhooks because I considered that if my database were to fail in the future, I would still need to think about database mapping issues; whereas webhooks are much simpler.
Simple Webhook
Based on my needs, I searched the WordPress plugin marketplace for a while and found that WP Webhooks could completely meet my requirements and had good ratings online. Unfortunately, after trialing it, I couldn’t get it to work for some reason, and I discovered that checking logs is a feature available only in the pro version…
Feeling stuck, and since my requirements are quite simple, I developed a WordPress plugin myself called Simple Webhook. You can find it here to download and install:
Once you’ve installed it, you can find the configuration URL in the settings interface. Set up the webhook, and the plugin will automatically send some basic information via POST whenever you publish a new article:
With this setup, combined with n8n and Polylang, you’ll have a multilingual WordPress site with ease.
Leave a Reply