React Native theorytheory 0/50 · 0%
Tooling · medium

35. Internationalization

Formatting numbers, currency and dates for a global audience.

`Intl` is available in modern React Native and is the right tool for formatting currency, numbers and dates correctly per locale, rather than hand-rolling string concatenation.

function formatUsd(amount: number, locale = "en-US") {
  return new Intl.NumberFormat(locale, { style: "currency", currency: "USD" }).format(amount);
}

formatUsd(1234.5); // "$1,234.50"

Token amounts often need custom formatting beyond `Intl` (e.g. showing 18-decimal precision truncated sensibly), so a dedicated `formatTokenAmount` helper alongside `Intl` is common.

Check your understanding

  1. 1. What built-in API formats currency per locale?

  2. 2. Why might token amounts need custom formatting beyond Intl?

  3. 3. What locale-aware behavior does Intl handle well?