2026-07-14

Internationalization (i18n) for Web Applications

Internationalization: Making Your Website Speak Multiple Languages

Internationalization (i18n) is the practice of designing your website so it can be adapted to different languages and regions. A well-internationalized website can be translated into new languages without rewriting code, and it handles things like date formats, currencies, and text direction correctly for each locale.

Separating Text from Code

The fundamental principle of internationalization is never to hardcode text. Instead of writing 'Welcome' directly in your template, you use a function like t('welcome') that looks up the translation for the current language. The translations are stored in separate files, one per language, so adding a new language just means adding a new translation file.

Translation files are typically JSON objects with keys for each string. The English file might have 'welcome': 'Welcome', and the Italian file would have 'welcome': 'Benvenuto'. This separation means translators can work on the translation files without touching the code.

Handling Plurals and Variables

Simple text replacement isn't enough. Different languages have different plural rules. English has two forms (one, other), but Arabic has six, and Japanese has essentially one. A good i18n library handles this automatically — you specify the translation for each plural form, and the library picks the right one based on the count.

Variables in translations are also handled differently by different languages. In English, you might say 'Hello, {name}' — the variable appears in a specific position. In other languages, the word order might be different. A good library handles this by allowing named placeholders and letting translators rearrange them as needed.

Dates, Numbers, and Currencies

Different regions format dates, numbers, and currencies differently. Americans write 04/01/2024 (April 1), Europeans write 01/04/2024, and Japanese write 2024/04/01. Numbers use different separators: 1,234.56 in the US versus 1.234,56 in much of Europe. Currencies have different symbols and different placement rules.

The Intl API built into modern browsers handles all of this. Intl.DateTimeFormat, Intl.NumberFormat, and Intl.RelativeTimeFormat format dates, numbers, and relative times correctly for the user's locale. You don't need a library for this — the browser handles it.

Text Direction and Layout

Not all languages are read left to right. Arabic, Hebrew, Persian, and Urdu are written right to left. Your layout needs to handle this — the text should flow from right to left, and the UI should mirror accordingly. CSS has logical properties (margin-inline-start, padding-inline-end) that automatically adapt to the text direction, so you don't need separate stylesheets for left-to-right and right-to-left.

Popular i18n Libraries

For JavaScript projects, the most popular library is i18next. It's framework-agnostic but has integrations for React, Vue, and other frameworks. It handles pluralization, interpolation, formatting, and more. For React specifically, react-intl and react-i18next are popular choices. The key is to choose a library and integrate it early — retrofitting i18n into an existing application is much harder than building it in from the start.

Let's work together

Do you need more info, help with your project, or to develop an idea?

Whether it's an easy question, a quick doubt, or just a 5-minute chat, send me a message—it costs nothing and I'm always ready to help. I love discussing a problem to understand it, getting creative with solutions, and focusing on simple, reliable, and straightforward ideas that we can actuate quickly.

Contact me

Switch Topic

Choose a specialized topic to explore: