104
LVL 04 — SENIOR-IN-TRAININGSESSION 104DAY 104

I18N LOCALIZATION

🎫 PIXELCRAFT-090
Feature | 🟡 Medium | Priority: 🟡 Medium

PixelCraft is English-only. Add i18n support for at least 3 languages. All UI text must be translatable. Support RTL (right-to-left) for Arabic/Hebrew. PixelCraft goes global.
CONCEPTS.UNLOCKED
🌍
i18n (Internationalization)
Designing software to support multiple languages. i18n is the architecture: extracting all text into translation files, handling plurals, formatting dates/numbers. Do it once, support any language.
🗺️
l10n (Localization)
Actually translating for a specific locale. l10n is the content: translating strings, adapting date formats, currency, and cultural conventions. i18n enables it; l10n fills in the blanks.
📄
Translation Files
JSON keyed by language code. en.json, es.json, ja.json. Each file maps the same keys to localized strings. The app loads the right file based on the user's language preference.
↩️
RTL Layout
dir="rtl" flips the entire layout. Arabic and Hebrew read right-to-left. CSS logical properties (margin-inline-start instead of margin-left) make layouts direction-agnostic automatically.
🔢
Pluralization Rules
Languages have different plural forms. English: 1 image / 2 images (2 forms). Russian: 1 изображение / 2 изображения / 5 изображений (3 forms). Arabic has 6 forms. i18next handles this.
📅
Intl API
Intl.DateTimeFormat, Intl.NumberFormat. Built-in browser API for locale-aware formatting. Feb 18, 2026 (en) → 18 feb 2026 (es) → 2026年2月18日 (ja). No libraries needed.
HANDS-ON.TASKS
01
Set Up i18next
npm install react-i18next i18next
02
Create Translation Files
// locales/en.json { "toolbar": { "upload": "Upload", "grayscale": "Grayscale", "brightness": "Brightness", "export": "Export" }, "gallery": { "title": "Your Gallery", "empty": "No images yet." + " Upload your first!", "imageCount": "{{count}} image", "imageCount_plural": "{{count}} images" } } // locales/es.json { "toolbar": { "upload": "Subir", "grayscale": "Escala de grises", "brightness": "Brillo", "export": "Exportar" }, "gallery": { "title": "Tu Galería", "empty": "Aún no hay imágenes." + " ¡Sube la primera!", "imageCount": "{{count}} imagen", "imageCount_plural": "{{count}} imágenes" } } // locales/ja.json { "toolbar": { "upload": "アップロード", "grayscale": "グレースケール", "brightness": "明るさ", "export": "エクスポート" }, "gallery": { "title": "ギャラリー", "empty": "まだ画像がありません", "imageCount": "{{count}}枚の画像" } }
03
Use Translations in Components
import { useTranslation } from 'react-i18next'; function Toolbar() { const { t } = useTranslation(); return ( <nav> <button> {t('toolbar.upload')} </button> <button> {t('toolbar.grayscale')} </button> <button> {t('toolbar.brightness')} </button> <button> {t('toolbar.export')} </button> </nav> ); } // Pluralization (automatic): function ImageCount({ count }: { count: number }) { const { t } = useTranslation(); return <p> {t('gallery.imageCount', { count })} </p>; // 1 → "1 image" // 5 → "5 images" // (auto-selects plural form) }
04
RTL Support
// Set document direction <html dir={isRTL ? 'rtl' : 'ltr'} lang={currentLanguage}> // CSS: logical properties instead // of physical .toolbar { padding-inline-start: 8px; /* Instead of padding-left */ margin-inline-end: 12px; /* Instead of margin-right */ } .sidebar { inset-inline-start: 0; /* Instead of left: 0 */ } // Logical properties flip // automatically when dir="rtl". // No separate RTL stylesheet needed.
05
Date & Number Formatting
// Built-in Intl API — no library needed // Dates: new Intl.DateTimeFormat('en', { dateStyle: 'long' }) .format(new Date()); // → "February 18, 2026" new Intl.DateTimeFormat('ja', { dateStyle: 'long' }) .format(new Date()); // → "2026年2月18日" // Numbers: new Intl.NumberFormat('en') .format(1234567); // → "1,234,567" new Intl.NumberFormat('de') .format(1234567); // → "1.234.567" // File sizes: function formatFileSize( bytes: number, locale: string ) { const mb = bytes / (1024 * 1024); return new Intl.NumberFormat(locale, { maximumFractionDigits: 1 }).format(mb) + ' MB'; }
06
Close the Ticket
git switch -c feature/PIXELCRAFT-090-i18n git add src/ locales/ git commit -m "Add i18n: en, es, ja + RTL support (PIXELCRAFT-090)" git push origin feature/PIXELCRAFT-090-i18n # PR → Review → Merge → Close ticket ✅
CS.DEEP-DIVE

Unicode is the foundation of internationalization.

It assigns a unique code point to every character in every human script: 149,186 characters across 161 scripts.

// Unicode + UTF-8:

Unicode = character → number
  A → U+0041
  и → U+0438
  字 → U+5B57
  🎨 → U+1F3A8

UTF-8 = number → bytes
  ASCII (Latin): 1 byte
  Cyrillic, Arabic: 2 bytes
  CJK (Chinese/Japanese): 3 bytes
  Emoji: 4 bytes

// JavaScript gotcha:
"hello".length === 5  // ✅
"こんにちは".length === 5 // ✅
"🎨".length === 2     // ⚠️
// JS counts UTF-16 code units,
// not characters. Emoji = 2 units.
// Use [...str].length for true count.

// Understanding encoding prevents
// mojibake (garbled text) — an
// entire class of bugs.
"i18n Lab"
[A]Add Arabic (ar.json) translation and test RTL layout. Every element should flip: sidebar on the right, text aligned right, icons mirrored. Screenshot and compare with English LTR layout.
[B]Add language detection: check navigator.language on first visit, fall back to English. Store the preference in localStorage. Respect the Accept-Language header on the server for SSR pages.
[C]Research: what is ICU MessageFormat? How does it handle complex pluralization, gender, and number formatting across languages? Compare to i18next's simpler approach. When does the complexity justify ICU?
REF.MATERIAL
ARTICLE
i18next Team
Official React integration for i18next: hooks, components, SSR support, pluralization, and namespaces. The standard React i18n solution.
I18NOFFICIALESSENTIAL
VIDEO
Codevolution
Practical react-i18next tutorial: setup, translation files, pluralization, interpolation, and language switching.
I18NTUTORIAL
ARTICLE
MDN Web Docs
Official reference: inline-start, block-end, and all logical properties. Write direction-agnostic CSS that works for LTR and RTL automatically.
CSSRTLESSENTIAL
ARTICLE
MDN Web Docs
Built-in internationalization: DateTimeFormat, NumberFormat, Collator, PluralRules. Locale-aware formatting without external libraries.
INTLOFFICIAL
VIDEO
Fireship
Quick i18n overview: translation files, RTL, pluralization, date/number formatting. The challenges of building for a global audience.
I18NQUICK
// LEAVE EXCITED BECAUSE
PixelCraft works in English, Spanish, and Japanese. Switch languages → entire UI translates instantly. Switch to Arabic → layout flips to RTL. PixelCraft is world-ready.