# @formatjs/intl-localematcher

> Intl.LocaleMatcher ponyfill

Latest version **0.9.0** (published 2026-09-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @formatjs/intl-localematcher
pnpm add @formatjs/intl-localematcher
yarn add @formatjs/intl-localematcher
bun add @formatjs/intl-localematcher
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.9.0 |
| Published | 2026-09-12 |
| First published | 2021-02-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Dependencies | 1 |
| Unpacked size | 236.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| Author | Long Ho <holevietlong@gmail.com> |
| Maintainers | longlho, redonkulus, pyrocat |
| Keywords | ecma402, formatjs, i18n, intl, locale, react-intl, tc39 |

## Links

- npm: https://www.npmjs.com/package/@formatjs/intl-localematcher
- Repository: formatjs/formatjs
- Homepage: https://github.com/formatjs/formatjs#readme
- Issues: https://github.com/formatjs/formatjs/issues
- npm.io page: https://npm.io/package/@formatjs/intl-localematcher

## Dependencies (1)

- [@formatjs/fast-memoize](https://npm.io/package/@formatjs/fast-memoize.md) 3.1.7

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 0.9.0 (latest) — 2026-09-12
- 0.8.14 — 2026-09-12
- 0.8.13 — 2026-07-16
- 0.8.12 — 2026-07-11
- 0.8.11 — 2026-07-09
- 0.8.10 — 2026-06-04
- 0.8.9 — 2026-05-27
- 0.8.8 — 2026-05-15
- 0.8.7 — 2026-05-12
- 0.8.6 — 2026-05-05
- 0.8.5 — 2026-04-29
- 0.8.4 — 2026-04-24
- 0.8.3 — 2026-04-13
- 0.8.2 — 2026-03-16
- 0.8.1 — 2026-02-01
- … 59 more at https://npm.io/package/@formatjs/intl-localematcher/versions

## README

# Intl LocaleMatcher

We've migrated the docs to https://formatjs.github.io/docs/polyfills/intl-localematcher.

## Performance

This package implements a highly optimized three-tier locale matching algorithm that provides excellent performance even with large locale sets (700+ locales).

### Benchmark Results

Benchmarked with 725 CLDR locales on Node.js:

| Scenario                                                | Latency | Throughput | Relative Performance |
| ------------------------------------------------------- | ------- | ---------- | -------------------- |
| **Tier 1: Exact Match** (`en`)                          | 1.38ms  | 730 ops/s  | Baseline             |
| **Tier 2: 1-level Fallback** (`en-US` → `en`)           | 1.39ms  | 725 ops/s  | 1.01x slower         |
| **Tier 2: Maximized Match** (`zh-TW` → `zh-Hant`)       | 1.40ms  | 720 ops/s  | 1.02x slower         |
| **Tier 3: CLDR Distance** (`sr-Latn-BA` → `sr-Latn-BA`) | 1.38ms  | 730 ops/s  | 1.00x slower         |
| **Tier 3: Fuzzy Match** (`en-XZ` → `en`)                | 1.50ms  | 670 ops/s  | 1.09x slower         |

### Real-world Impact

The optimization in this package resolved [issue #4936](https://github.com/formatjs/formatjs/issues/4936), where `DurationFormat` instantiation was taking **610ms** on React Native/Hermes due to slow locale matching against 700+ auto-loaded locales.

**After optimization:**

- Common case (`en-US`): **1.39ms** per instantiation
- Chinese locales (`zh-TW`): **1.40ms** per instantiation
- Serbo-Croatian locales: **1.38ms** per instantiation

**Performance improvement: 439x faster** 🚀

### Three-Tier Optimization

The algorithm uses three tiers for maximum performance:

1. **Tier 1 (Exact Match)**: O(1) Set lookup for exact locale matches
2. **Tier 2 (Maximization + Fallback)**: Progressive subtag removal with locale maximization
3. **Tier 3 (CLDR Distance)**: Full UTS #35 Enhanced Language Matching with memoization

This design ensures that common cases (exact matches and simple fallbacks) are extremely fast, while complex scenarios (script/region matching, language distances) still perform well.

---
_Source: https://npm.io/package/@formatjs/intl-localematcher · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
