React
1.2M weekly downloads

React Localization with react-intl

Format.js provides robust internationalization. ICU MessageFormat standard. Built-in date, number, and currency formatting. 1.2M weekly downloads.

Prerequisites

  • React 18+ application
  • Node.js 18+
  • Understanding of ICU MessageFormat (optional)

Common Challenges

Problems developers face when localizing React apps—and how IntlPull helps.

ICU Syntax Learning Curve

ICU MessageFormat is powerful but complex. Teams need training on plural rules and select statements.

Message Extraction Setup

Setting up babel plugin and extraction pipeline requires configuration. Not plug-and-play.

Bundle Size

CLDR data adds weight. Need to configure locale data loading carefully for production.

react-intl Features

Why react-intl is a great choice for React localization.

ICU MessageFormat

Industry-standard message syntax. Complex plurals, selects, and nested formatting in one string.

vs custom interpolation

Built-in Formatters

Format dates, numbers, currencies, and relative times. Locale-aware out of the box.

vs manual formatting

Extraction Tools

CLI extracts messages from code. AST-based, catches all usages. Integrates with babel.

vs manual string tracking

TypeScript Support

First-class TypeScript support. Type-safe message IDs. Autocomplete for formatters.

vs runtime errors

React API

useIntl hook and FormattedMessage component. Flexible API for different use cases.

vs string-only solutions

CLDR Data

Uses Unicode CLDR data. Accurate locale rules for 200+ languages.

vs simplified rules

Quick Setup

Get react-intl running in your React project.

1

Install Dependencies

Add react-intl to your project.

npm install react-intl
2

Create IntlProvider

Wrap your app with IntlProvider.

import { IntlProvider } from 'react-intl';
import messages from './locales/en.json';

function App() {
  return (
    <IntlProvider messages={messages} locale="en" defaultLocale="en">
      <YourApp />
    </IntlProvider>
  );
}
3

Use FormattedMessage

Use the FormattedMessage component for translations.

import { FormattedMessage } from 'react-intl';

function Welcome() {
  return (
    <h1>
      <FormattedMessage
        id="welcome.title"
        defaultMessage="Welcome to {appName}"
        values={{ appName: 'IntlPull' }}
      />
    </h1>
  );
}
4

Use useIntl Hook

For programmatic access and formatting.

import { useIntl } from 'react-intl';

function PriceDisplay({ price }: { price: number }) {
  const intl = useIntl();
  
  return (
    <span>
      {intl.formatNumber(price, {
        style: 'currency',
        currency: 'USD'
      })}
    </span>
  );
}

IntlPull Integration

Connect IntlPull to manage translations professionally.

1

Install CLI and Extract Plugin

Add tools for message extraction.

npm install -D @formatjs/cli @intlpull/cli
2

Extract Messages

Extract message IDs from your codebase.

npx formatjs extract 'src/**/*.tsx' --out-file extracted.json --id-interpolation-pattern '[sha512:contenthash:base64:6]'
3

Push to IntlPull

Upload extracted messages for translation.

npx intlpull push --source extracted.json --format formatjs
4

Pull Translations

Download translated messages.

npx intlpull pull --format formatjs --output ./src/locales

Frequently Asked Questions

Ready to Localize Your React App?

Start with our free tier. No credit card required.

    React Intl (Format.js) Guide | IntlPull | IntlPull