
ComBox is the theme I run on my own blog — a minimal, single-column Typecho theme. There's a write-up here: ComBox — a minimal Typecho theme built for reading
As you can see, the blog now runs in three languages: Simplified Chinese, Traditional Chinese, and English. Here's a quick look at the thinking behind the multilingual version, and how it actually works.
In the V1.1 release I added multilingual support: three interface languages — Simplified Chinese, Traditional Chinese, English. I translated the interface thoroughly. Menus, buttons, date formats, "Read more," comment prompts, share text — all of it switched with the language. But it ran into a hard physical limit: the post body never changed. Flip the language and "Search" becomes "Search" in English, the footer's privacy link becomes "Privacy Policy," but open a post and it's still Chinese.
For a site written only for Chinese (or single-language) readers, that's plenty. But once you've built multilingual features, calling this half-done version multilingual is a stretch.
Analysis: four routes, each with its trade-offs
Once I'd worked through the requirements, the options weren't many. In the Typecho ecosystem there are exactly four.
Option 1: the ?lang= parameter (what V1.1 did)
One URL, with a query parameter deciding the language.
- Upside: the least work — a single
ifswitches it. - Downside: crawlers don't carry parameters. When Googlebot fetches
/archives/x.html, it always gets the default language; the other two don't exist as far as it's concerned. And one URL serving different content to different people breaks caching plugins and CDNs alike.
This route works for interface language only, never for content.
Option 2: duplicating the whole site
Copy the entire site into an /en/ directory (or onto a subdomain), give it its own database, and translate the theme strings a second time. Nearly every tutorial you'll find takes this route, and it does work.
But maintaining it in practice costs this much — one site owner's account of it:
| Problem to solve | What it costs |
|---|---|
The two sites' post URLs differ only by the /en prefix | The cid values must match exactly, so you need a sync plugin that inserts a row with the same cid into the English database whenever the Chinese site publishes |
| View counts and likes have to line up | The English site's counters must write back into the Chinese database |
| Comments have to be readable in both places | Two comment tables need to sync with each other |
| Sitemap | One sitemap can't both list pages and reference other sitemaps, so it splits into two plus an index |
Every row means code to write and failure modes to handle — and if any one sync breaks, nothing raises an alarm. You just discover one day that the English site's view counts froze three months ago.
The root problem: it takes the idea of "one post" and physically splits it in two, then uses synchronization to pretend they're one.
Option 3: language as a category
Create two categories, "Chinese posts" and "English Posts," and publish into each separately.
- Upside: zero development.
- Problem: category and language are orthogonal. Mix them and "Technology" as a category stops working on the English side; tags, archives, and search all need rethinking. It treats language as a property of content instead of a property of the visit.
Option 4: one database + translation table + URL prefix
A post still has exactly one primary record. Translations live in their own table, keyed by (cid, lang). The URL prefix picks the language.
That's what I went with. It satisfies four requirements at once:
- The body is readable → the translation table holds that language's
title/text - The admin panel doesn't turn into an assembly line → one original plus some translations; you still publish once
- SEO stays clean → three languages are three real addresses, each with its own canonical and mutual hreflang
- No touching legacy data → the main table changes not one row; the translation table is new
The four side by side
?lang= parameter | Duplicated sites | Category-based | One DB + translations | |
|---|---|---|---|---|
| Crawlers see all three languages | No | Yes | Yes | Yes |
| Same URL, stable content | No | Yes | Yes | Yes |
| Views and comments shared by nature | — | Needs sync | No | Shared by nature (all hang off cid) |
| Publish once | Yes | No (publish twice) | No | Yes |
| Migrate legacy data | No | Yes (sync cid) | No | No |
| Implementation complexity | Low | Medium (lots of sync logic) | Low | Medium-high |
The problems: where it actually got stuck
Picking an approach is the easy part. Here's what really came up during development and launch.
Problem 1: what gets to decide the language
V1.1 resolved it in five layers: parameter, cookie, admin setting, browser preference, fallback. The more layers, the higher the odds that the same person sees a different language on two visits — and the harder caching gets.
V2.0 cut it to one: the address is the only answer. A prefix fixes the language. No cookies, no browser preferences, no second redirect. The only redirect happens on a first visit to the home page when the admin has set a guided language; after that, the address decides everything.
Problem 2: where the body lives, and how to keep the versions from bleeding into each other
Translations are stored separately and hung beneath the original by post ID — a translation is a dependent, not a copy.
Views, comments, pinned status, likes all attach to the original. All three languages are reading the same post, so those numbers are shared by nature and need no syncing. "Store one post three times" can't do that: counts fork by nature, and you can only force them together with sync, which drifts sooner or later.
Problem 3: what to return when a page has no translation
There are four wrong answers: a 404 (the post exists, and this gets that version dropped from the index), the Chinese original (no progress at all, plus duplicate content), a blank page (users assume the site is broken), or an error.
What I chose: open normally, tell search engines not to index it, and show an explanatory page. Once the translation lands, the same URL is back in the index immediately. The language name on that page is dynamic and follows the current root language.
Problem 4: after switching the root, which version is "the original"
It sounds like a routing change. Halfway through I found I'd only changed half of it: the front end's / was English, but editing that same post in the admin panel still showed Chinese in the main field — the two didn't line up. The root cause was that "main content is always Simplified Chinese" was hardcoded in several places. After the switch, those checks all pointed wrong: search went looking for translations that didn't exist, and lists treated untranslated posts as translated.
Two steps fixed it. First, every check goes through "the current root language." Second, at the moment of switching, the content itself has to switch too — the body you've stored is no longer the original. The second step is destructive, so it's one atomic operation: all or nothing. Early versions committed in two passes, and a failure in between meant the user's next save switched it again — data scrambled.
And one thing you must not do: after switching, don't redirect the old addresses to new ones inside the site. The addresses overlap completely; the same address now serves different content. A redirect would permanently pin the new version to the old address.
Problem 5: switching is slow, and "roll back on failure" was a lie
The first version worked, but the switch took ten seconds: a per-post loop, four hundred-odd posts, four thousand queries. Locally it just felt slow. On a server it reads as "clicked, nothing happened, user clicks again thinking it broke."
While optimizing, I found something worse: "roll back on failure" never actually fired. Reads and writes went through two separate channels — rollback on one, writes on the other — so nothing rolled back. Running the whole block on a single channel is what made it real.
The lesson: "I used an atomic operation" and "the atomic operation actually worked" are two different claims. Destructive changes need a control group.
Problem 6: translating three hundred-odd tags
Three hundred tag entries in the admin panel, each needing an English name typed by hand — the kind of chore that makes people give up on multilingual entirely.
So I added spreadsheet import and export: export to CSV, open it in Excel without mojibake, translate, import back, and only changed rows update. A wrong language column rejects the whole batch. Importing unchanged data changes nothing. AI draft generation is still there, but it only fills drafts and a human must save — shipping machine output straight to production throws away all the good intentions above.
Problem 7: does a single-language site need the theater
A pure Simplified Chinese site doesn't need Traditional and English addresses hanging around. Turn them off and: addresses redirect to the same path under the root language, the switcher is hidden outright instead of grayed out, multilingual declarations stop outputting, the sitemap index collapses to one file, and the translation panel doesn't render at all. Not one row of data is deleted — tick it back on and everything returns.
One detail that's easy to miss: the save button must not be fooled by an empty form. When the page has no editable language left but the request still carries the old language parameter, the batch must be rejected — that kind of bad write is almost impossible to catch afterward.
Problem 8: Chrome flattened the sitemap
A standard sitemap can embed language declarations in each URL entry, completely within spec. But Chrome, which normally renders these files as a collapsible tree, degrades to plain text the moment that element appears. I suspected file size, namespaces, compression — none of it. Only a controlled experiment confirmed it was the element itself.
So I compromised: language declarations inside the sitemap are off by default; the ones in the page head still output. Search engines trust the head, and a sitemap a human can read at a glance is worth more.
A few fixes along the way: Chinese characters in URLs must be escaped per the rules or the sitemap addresses won't match the pages; illegal characters get filtered; caches validate the domain; direct requests to plugin source files must not return a normal page.
The solution: what it finally became
1. URL structure
| Address | Content |
|---|---|
/ | Root language (Simplified by default) |
/zh-tw/ | Traditional Chinese |
/en/ | English |
/zh-cn/, ?lang=en | V1.1's old format; redirects to the new address |
Three languages, three real addresses, each indexable and shareable. The switcher is three ordinary links, not scripted buttons — so the back button goes back one step at a time.
2. One original, three readings
The original exists once. Translations sit beside it.
- Shared: views, comments, likes, pinned status, publish date, author, category, tags
- Per language: title, body, excerpt, keywords, SEO description
- Category and tag names per language, and site-level strings (site description, footer text), are stored separately
3. Admin, day to day
When editing a post, a row of language tabs sits above the body (named after the root language). Fill it in and save.
- Translations have two states, draft and published; drafts stay private, so you can save now and keep revising
- If the original has changed, the translation panel flags "based on an older version" — a reminder, not a forced retranslation
- Deleting a translation means ticking "remove this language's translation"; clearing the fields isn't enough — that leaves a "published but empty" row, so the front end shows Chinese while the list still counts it. I've been bitten by that, which is why deletion removes the whole row
4. SEO
Every page declares three things: which page it is, where the other language versions live, and where the default lands. The first matters most — each page points only at itself, never at the root language. Three languages are three separate pages, not three copies of one.
- List only the versions that actually exist. A language with no translation doesn't appear in the declarations, or you're telling search engines "there's an English version here" and sending visitors to a notice page
- With only one language enabled, the whole block of declarations isn't output
- One sitemap per language plus a master; pages and posts ordered newest first — order doesn't matter to search engines, but fixing it lets a human check at a glance whether it's right
- robots.txt doesn't advertise the sitemap. Want to submit it? Do it by hand in Search Console once. Don't let an auto-discovery link make that call for you
Optimization: from "it works" to "it holds up"
1. Performance
| Item | V2.0 | V2.1 |
|---|---|---|
| Root switch | Per-post queries, 4,000 of them, ~10 seconds | Batched, a hundred-odd milliseconds |
| Language detection | Five-layer chain | One layer: read the URL prefix |
| Static assets | Off-site fonts and CDN | All local, zero external requests |
2. Correctness
- A root switch is one atomic operation: content and settings succeed together, or neither takes effect
- Root switches require a second confirmation: the dialog states plainly that address ownership changes, the site itself can't undo it, and the search engines need to be updated. You must tick the box to save. Think it through and go ahead — but don't click through half-asleep. Afterward there's a 90-day watch-period notice
- Duplicate prefixes collapse automatically:
/en/en/xxxredirects to/en/xxxinstead of throwing an error full of server paths - If the original changed and the translation is stale, the admin panel says so
- Spreadsheet imports validate the whole batch: wrong language, bad header row, over the limit — the batch is rejected, never half-written
3. Degradation
Multilingual is a plugin capability, so the theme has to survive its absence:
| Scenario | Behavior |
|---|---|
| ComLang not enabled | Falls back to interface languages; the site runs normally, just without translated bodies |
| A post has no translation, or only a draft | Notice page, no original body output |
| A post wasn't backfilled after a root switch | Notice page; posts keep their title as an anchor, standalone pages clear the title too |
| Only one language enabled | Switcher and language declarations hidden entirely |
One principle: no anomaly may become an error, a blank screen, or mixed Chinese and English.
A few lessons
Language can't live in a cookie. Once language becomes "visitor state," the same address must serve different content to different people — a disaster for caching, sharing, and crawlers. It belongs in the address.
"The language of the main content" has to be a variable. The moment the code contains a hardcoded "if it isn't Simplified, use the translation," the root language is nailed down. A root switch means hunting all of them down — scattered across templates, search, the sitemap, the admin panel — and one missed spot is one dead link.
Destructive operations must be repeatable, atomic, and provable. "I added a rollback" and "the rollback works" are different claims, and there's exactly one test: a control group. Insert a row, roll back, see whether it's still there.
Don't make translation a precondition for publishing. If every post requires three languages up front, the third rarely arrives at all. Allow "this one is Chinese only," allow drafts, allow filling it in later — that's what keeps the scheme alive.
A root switch can't lean on in-site redirects to keep pages indexed. Easiest to get wrong: before and after the switch the addresses overlap completely, with the same address serving new content. Redirecting then pins the new content to the old address forever. Let the new structure take effect immediately, then change the address in Search Console.
What didn't change
Still one column, five or six posts per screen. The table of contents, the code window, the lightbox are all still there. Night mode is still warm dark gray. The share poster is drawn in your own browser, so no address goes to a third party. Assets ship with the theme, so it renders complete even offline. Multilingual comes from two plugins; without them it falls back to interface languages and the site runs as usual — no blank screens, no errors.
What kind of site it suits
It was built for sites where one person does the writing. It feels right in these cases:
- Personal blogs, especially slow ones where a single post is worth three of someone else's.
- Technical notes — code window, syntax highlighting, light and dark both ready; easy on the eyes at night.
- Sites that want to reach Chinese and overseas readers at once. If the whole site won't translate, start with the dozen posts that matter most.
- Long series — dozens of posts on one subject, held together by the table of contents and pinned posts.
- Small resource sites — a few explainers, a links page, a gallery. Enough, and not bloated.
Version pairing: ThemeComBox 2.1.0+ComLang 1.1.0(required) +ComSiteMap 1.0.2(optional)
Comments No Comments