Intl.LocaleMatcher ponyfill providing comprehensive locale matching algorithms with support for 'lookup' and 'best fit' strategies
94
Build a locale fallback resolver that implements a hierarchical locale matching algorithm. Given a requested locale and a list of available locales, your resolver should find the best match by progressively removing subtags from right to left.
Your resolver should:
The fallback chain should work as follows:
@generates
/**
* Finds the best available locale using progressive subtag removal
* @param requestedLocale - The locale identifier to match (e.g., "en-Latn-US")
* @param availableLocales - Array of available locale identifiers
* @returns The matched locale string or undefined if no match found
*/
export function findBestAvailableLocale(
requestedLocale: string,
availableLocales: string[]
): string | undefined;Provides locale matching and resolution algorithms.
@satisfied-by
Install with Tessl CLI
npx tessl i tessl/npm-formatjs--intl-localematcherdocs
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
scenario-10