FormatJS
FormatJS
DocsAPI ReferencesPolyfillsTooling
GitHub

Getting Started

  • Installation
  • Message Declaration
  • Message Extraction
  • Message Distribution
  • Application Workflow

Core Concepts

  • Basic Internationalization Principles
  • ICU Message Syntax

React Intl

  • Overview
  • API
  • Components
  • Upgrade Guide 2.x
  • Upgrade Guide 3.x
  • Upgrade Guide 4.x
  • Upgrade Guide 5.x

Polyfills

  • Overview
  • Intl.DateTimeFormat
  • Intl.DisplayNames
  • Intl.DurationFormat
  • Intl.GetCanonicalLocales
  • Intl.ListFormat
  • Intl.Locale
  • Intl.LocaleMatcher
  • Intl.NumberFormat
  • Intl.PluralRules
  • Intl.RelativeTimeFormat
  • Intl.Segmenter
  • Intl.supportedValuesOf

Tooling

  • CLI
  • Babel Plugin
  • TypeScript Transformer
  • SWC Plugin
  • ESLint Plugin
  • Rust: ICU MessageFormat Parser
  • Rust: ICU Skeleton Parser

Guides

  • Testing with React Intl
  • Runtime Requirements
  • Advanced Usage
  • Bundler Plugins
  • Distribute Libraries
  • Development

Other APIs

  • @formatjs/intl
  • Vue Intl
  • Intl MessageFormat
  • ICU MessageFormat Parser
  1. Home
  2. Docs
  3. Polyfills
  4. Intl Localematcher

A spec-compliant ponyfill for Intl.LocaleMatcher. Since this is only stage-1 this package is a ponyfill instead of polyfill.

npm Version size

Installation#

npm i @formatjs/intl-localematcher

Requirements#

  • Intl.getCanonicalLocales or polyfill
  • Intl.Locale or polyfill

Usage#

Simple#

match(['fr-XX', 'en'], ['fr', 'en'], 'en') // 'fr'

match(['zh'], ['fr', 'en'], 'en') // 'en'