@phensley/locale-matcher
v1.9.2
Published
Implements CLDR enhanced language matching
Downloads
10,297
Readme
@phensley/locale-matcher
Implements distance based locale matching using the CLDR enhanced language matching algorithm.
Installation
NPM:
npm install --save @phensley/locale-matcher
Yarn:
yarn add @phensley/locale-matcher
Examples
import { LocaleMatch, LocaleMatcher } from '@phensley/locale-matcher';
// Add supported locales to matcher
const matcher = new LocaleMatcher('en, en_GB, zh, pt_AR, es-419');
let m: LocaleMatch;
// Query desired locales to find the nearest match
m = matcher.match('en-AU');
console.log(`distance ${m.distance} locale ${m.locale.id}`);
m = matcher.match('es-MX');
console.log(`distance ${m.distance} locale ${m.locale.id}`);
distance 3 locale en_GB
distance 4 locale es-419