FormatJS

FormatJS provides Rust crates for message formatting, locale negotiation, message extraction, ICU parsers, Java Formatter parsing, and Temporal date/time operations.

Choose a crate

CrateUse it for
formatjs_temporalTyped Temporal values, calendar arithmetic, and IANA time zones with an allocation-free no_std core
formatjs_intlApplication-level descriptors, translation catalogs, locale negotiation, and shared message caching
formatjs_icu_messageformatLow-level ICU MessageFormat formatting with a locale supplied for each call
formatjs_intl_macrosProcedural macro used by formatjs_intl::message_descriptor!; applications normally depend on formatjs_intl instead
formatjs_icu_messageformat_parserParsing ICU MessageFormat into a strongly typed AST
formatjs_icu_skeleton_parserParsing ICU number and date/time skeletons
formatjs_cliExtracting, compiling, and verifying messages from the formatjs command

Use formatjs_intl for a Rust backend with translation catalogs. Use formatjs_icu_messageformat when message selection, locale negotiation, and catalog loading already happen elsewhere.

For Android-style printf syntax, use formatjs_java_printf_parser. It parses Java Formatter syntax without depending on ICU or formatting runtime values. For iOS/macOS Foundation formats, use formatjs_apple_printf_parser, including object placeholders, length modifiers, and dynamic width/precision arguments.

Runtime layers

formatjs_intl
├── message_descriptor! and stable message IDs
├── MessageCatalog and ICU4X locale negotiation
├── IntlCache shared across requests
└── formatjs_icu_messageformat
    ├── ICU MessageFormat parser
    ├── ICU skeleton parser
    └── ICU4X number, date/time, and plural formatting

Rust message workflow

Declare messages next to their use:

use formatjs_intl::{MessageDescriptor, message_descriptor};

const GREETING: MessageDescriptor = message_descriptor!(
    default_message: "Hello, {name}!",
    description: "Greeting shown after sign-in"
);

Extract descriptors with the native CLI:

cargo install formatjs_cli
formatjs extract "src/**/*.rs" --out-file messages.json

When id is omitted, the macro and extractor generate the same ID with [sha512:contenthash:base64:10]. Add id: "greeting" when your application uses semantic IDs.

API documentation