Back to KB
Difficulty
Beginner
Read Time
14 min

Adding a third language to a static HTML site: ~60 lines of vanilla JS

By Codcompass Team··14 min read

Yesterday a lead from Ukraine asked to see my work. My case study was in Russian. Sending a Russian-language portfolio to a Ukrainian client is a good way to lose them before hello.

The site is static HTML on Vercel. No framework, no build step, and I wanted to keep it that way. An i18n library for two pages felt like overkill, so here's what I did instead.

Russian stays in the DOM, other languages are dictionaries

The page source is the Russian version. On load I walk all text nodes once and remember their original value, whitespace and a normalized key:

function norm(s){ return s.replace(/[\s ]+/g,' '

🎉 Mid-Year Sale — Unlock Full Article

Base plan from just $4.99/mo or $49/yr

Sign in to read the full article and unlock all 635+ tutorials.

Sign In / Register — Start Free Trial

7-day free trial · Cancel anytime · 30-day money-back