Translating Japanese news pages without breaking them
Japanese sites are a good stress test for page translation: the text translates fine, but the page around it often breaks.
Vladyslav Korzh Engineering2 min read
Words cut in half
Japanese has no spaces, so many sites set word-break: break-all to let lines wrap between any two characters. Put English into that element and “speaks” becomes “spea / ks”. When the source language is Japanese, Chinese or Korean, we switch the translated page back to normal word breaks. Japanese still wraps between characters under that setting, so switching to the original stays correct.
Blank photos
Image CDNs protect their files in opposite ways. Some refuse requests with no Referer header, others refuse a foreign one. The magazine we tested answered 403 to both our original setting and to Google’s proxy. We now send the translator’s own address and, if a photo still fails, retry it once with no referrer. On that page, 16 of 16 photos loaded.
A header under the bar
A translation bar pinned to the top of the screen covers any site header pinned there too, and many headers pin themselves only after you scroll. We watch for elements that become fixed or sticky at the top and move them down by the bar’s height, then give them their original position back when they unpin.
Phone or desktop?
Sites often send different HTML to phones and desktops based on the browser’s user agent, not only CSS. Fetching every page as a desktop browser gave phone readers a tiny desktop layout. We now detect the reader’s device from the request and fetch and cache the two versions separately.
Translation quality didn’t need fixing
Across ten hosting providers and two models, the same Japanese paragraphs came back nearly word for word the same. The providers differed only in speed and reliability.