Skip to content
Insights

Make missing translations a compile error

Bilingual sites drift. One language gets a new paragraph, the other does not, and nobody notices for a quarter. The fix is a type, not a process.

5 min readWritten by Elite Algos Labs Engineering

Every bilingual project we have inherited had the same defect: the second language was behind. Not catastrophically — a missing button label here, an untranslated error message there — but consistently, because keeping two files in sync is a discipline problem, and discipline degrades under deadline.

The structural fix is to make one language the type source and every other language a value that must satisfy it.

// en.ts — the source of truth. Note: no `as const`.
export const en = {
  nav: { home: 'Home', about: 'About' },
}
export type Dictionary = typeof en

// fr.ts — cannot compile until every key exists.
import type { Dictionary } from './en'
export const fr: Dictionary = {
  nav: { home: 'Accueil', about: 'À propos' },
}
Omitting `as const` matters: with literal types, a translation would only compile if it were identical to the English.

Now a missing French string is not a content oversight discovered by a user — it is a red squiggle in the editor and a failed build in CI. The guarantee moves from "we remember to translate" to "it cannot ship otherwise".

TopicsArchitectureInternationalisation
All insights

Related reading

  • The gap between a demo and a system

    Most AI projects do not fail because the model was wrong. They fail because nobody engineered the twenty per cent of cases the demo never showed.

    The gap between a demo and a system