Engineering6 min read

Localization Engineer

Internationalizes web applications - i18n architecture, react-intl, pluralization, date and number formatting, RTL layout, and translation workflow design.

i18nl10nReactreact-intlpluralizationRTLdate formatting

The Localization Engineer designs i18n architecture for web applications - from message format choices to RTL layout support. It covers react-intl setup, pluralization rules, locale-aware date and number formatting, right-to-left support, and translation workflow design that scales from 2 to 40 locales without breaking engineers or translators. All patterns use the ICU Message Format and the Intl browser API.

Project Structure

src/
  i18n/
    en.json          // Source messages - English (base locale)
    fr.json          // Generated / maintained by translators
    ar.json
  hooks/
    useTranslation.ts
  providers/
    IntlProvider.tsx

// en.json - ICU Message Format
{
  "welcome": "Welcome, {name}!",
  "items_count": "{count, plural, =0 {No items} one {# item} other {# items}}",
  "last_seen": "Last seen {date, date, medium}",
  "price": "{amount, number, ::currency/USD .00}"
}

react-intl Setup

// IntlProvider.tsx - wraps the app at the root
import { IntlProvider } from 'react-intl';
import { useState, useEffect } from 'react';

const loadMessages = async (locale: string) => {
  switch (locale) {
    case 'fr': return import('../i18n/fr.json');
    case 'ar': return import('../i18n/ar.json');
    default:   return import('../i18n/en.json');
  }
};

export function AppIntlProvider({ children }: { children: React.ReactNode }) {
  const [locale, setLocale] = useState(() =>
    navigator.language.split('-')[0] // 'en-US' → 'en'
  );
  const [messages, setMessages] = useState({});

  useEffect(() => {
    loadMessages(locale).then(m => setMessages(m.default));
  }, [locale]);

  return (
    <IntlProvider locale={locale} messages={messages} defaultLocale="en">
      {children}
    </IntlProvider>
  );
}

Usage Patterns

import { useIntl, FormattedMessage, FormattedDate, FormattedNumber } from 'react-intl';

function OrderSummary({ order }) {
  const intl = useIntl();

  return (
    <div>
      {/* Simple message with variable */}
      <FormattedMessage id="welcome" values={{ name: order.customerName }} />

      {/* Pluralization - ICU plural handles English AND other languages' rules */}
      <FormattedMessage id="items_count" values={{ count: order.items.length }} />

      {/* Date - formats per locale (Aug 19, 2026 vs 19/08/2026) */}
      <FormattedDate value={order.createdAt} year="numeric" month="short" day="numeric" />

      {/* Number with currency - handles comma/period conventions */}
      <FormattedNumber value={order.totalCents / 100} style="currency" currency="USD" />

      {/* String with HTML - use values prop, not dangerouslySetInnerHTML */}
      <FormattedMessage
        id="terms_notice"
        values={{ link: (chunks) => <a href="/terms">{chunks}</a> }}
      />
    </div>
  );
}

RTL (Right-to-Left) Layout

/* CSS logical properties - direction-aware, no RTL-specific overrides needed */

/* ✅ Use logical properties */
.card {
  margin-inline-start: 1rem;   /* = margin-left in LTR, margin-right in RTL */
  padding-inline: 1.5rem;      /* horizontal padding, direction-aware */
  border-inline-start: 3px solid var(--accent); /* left border in LTR, right in RTL */
  text-align: start;           /* left in LTR, right in RTL */
}

/* ❌ Avoid physical properties for layout */
.card {
  margin-left: 1rem;           /* broken in RTL */
  text-align: left;            /* broken in RTL */
}

/* Set dir on html element - React apps should set this when locale changes */
// Set lang and dir attributes when locale changes
useEffect(() => {
  document.documentElement.lang = locale;
  document.documentElement.dir = ['ar', 'he', 'fa', 'ur'].includes(locale) ? 'rtl' : 'ltr';
}, [locale]);

Translation Workflow

StageToolOutput
Extract messages@formatjs/cli extractCanonical en.json with all message IDs
Find missing translations@formatjs/cli compile or CI diffList of IDs in en.json not in fr.json
Send to translatorsPhrase, Lokalise, or CrowdinTranslated JSON files per locale
Validate on mergeCI check: all IDs present, no empty stringsPR blocked if translations are incomplete
Pseudo-locale testingReplace chars with accented equivalentsCatches hardcoded strings and layout overflow before real translation

Common Mistakes

  • Concatenating strings - "Hello " + name breaks in languages where word order differs. Always use ICU messages with named placeholders.
  • Hardcoded date formats - new Date().toLocaleDateString() uses browser locale, not app locale. Always pass locale explicitly to Intl.DateTimeFormat or FormattedDate.
  • Assuming plural = one/many - Arabic has 6 plural forms; Russian has 4. ICU handles this correctly; custom plural logic does not.
  • Pixel-width layouts - German text is 30–40% longer than English. Use flexible layouts (min-width not fixed width) and test with de locale before launch.

Explore all agents

Browse the full library of specialized AI agents - Engineering, AI, Content, and Growth.