@formatjs/intl-localematcher
Intl.LocaleMatcher ponyfill
Last updated 4 months ago by longlho .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @formatjs/intl-localematcher 
SYNC missed versions from official npm registry.

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-USen) 1.39ms 725 ops/s 1.01x slower
Tier 2: Maximized Match (zh-TWzh-Hant) 1.40ms 720 ops/s 1.02x slower
Tier 3: CLDR Distance (sr-Latn-BAsr-Latn-BA) 1.38ms 730 ops/s 1.00x slower
Tier 3: Fuzzy Match (en-XZen) 1.50ms 670 ops/s 1.09x slower

Real-world Impact

The optimization in this package resolved issue #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.

Current Tags

  • 0.8.2                                ...           latest (a month ago)

61 Versions

  • 0.8.2                                ...           a month ago
  • 0.8.1                                ...           2 months ago
  • 0.8.0                                ...           3 months ago
  • 0.7.5                                ...           3 months ago
  • 0.7.4                                ...           3 months ago
  • 0.7.3                                ...           4 months ago
  • 0.7.2                                ...           4 months ago
  • 0.7.1                                ...           4 months ago
  • 0.7.0                                ...           4 months ago
  • 0.6.2                                ...           6 months ago
  • 0.6.1                                ...           a year ago
  • 0.6.0                                ...           a year ago
  • 0.5.10                                ...           a year ago
  • 0.5.9                                ...           a year ago
  • 0.5.8                                ...           a year ago
  • 0.5.7                                ...           a year ago
  • 0.5.6                                ...           a year ago
  • 0.5.5                                ...           a year ago
  • 0.5.4                                ...           2 years ago
  • 0.5.3                                ...           2 years ago
  • 0.5.2                                ...           2 years ago
  • 0.5.1                                ...           2 years ago
  • 0.5.0                                ...           2 years ago
  • 0.4.2                                ...           3 years ago
  • 0.4.1                                ...           3 years ago
  • 0.4.0                                ...           3 years ago
  • 0.3.0                                ...           3 years ago
  • 0.2.32                                ...           3 years ago
  • 0.2.31                                ...           4 years ago
  • 0.2.30                                ...           4 years ago
  • 0.2.29                                ...           4 years ago
  • 0.2.28                                ...           4 years ago
  • 0.2.27                                ...           4 years ago
  • 0.2.25                                ...           4 years ago
  • 0.2.24                                ...           4 years ago
  • 0.2.23                                ...           4 years ago
  • 0.2.22                                ...           4 years ago
  • 0.2.21                                ...           5 years ago
  • 0.2.20                                ...           5 years ago
  • 0.2.19                                ...           5 years ago
  • 0.2.18                                ...           5 years ago
  • 0.2.17                                ...           5 years ago
  • 0.2.16                                ...           5 years ago
  • 0.2.15                                ...           5 years ago
  • 0.2.14                                ...           5 years ago
  • 0.2.13                                ...           5 years ago
  • 0.2.12                                ...           5 years ago
  • 0.2.11                                ...           5 years ago
  • 0.2.10                                ...           5 years ago
  • 0.2.9                                ...           5 years ago
  • 0.2.8                                ...           5 years ago
  • 0.2.7                                ...           5 years ago
  • 0.2.6                                ...           5 years ago
  • 0.2.5                                ...           5 years ago
  • 0.2.4                                ...           5 years ago
  • 0.2.3                                ...           5 years ago
  • 0.2.2                                ...           5 years ago
  • 0.2.1                                ...           5 years ago
  • 0.2.0                                ...           5 years ago
  • 0.1.0                                ...           5 years ago
  • 0.0.1                                ...           5 years ago
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 25
Last Month 25
Dependencies (1)
Dev Dependencies (0)
None

Copyright 2013 - present © cnpmjs.org | Home |