@phensley/cldr-core
Version:
Core library for @phensley/cldr
36 lines (35 loc) • 1.17 kB
TypeScript
import { Locale } from './locale';
/**
* A result returned by the LocaleMatcher.
*
* @alpha
*/
export interface LocaleMatch {
locale: Locale;
distance: number;
}
/**
* Given a list of supported locales, and a list of a user's desired locales
* (sorted in the order of preference, descending), returns the supported
* locale closest to the user preference. The first locale in the list will
* be used as the default. The default will be selected if no match is within
* the distance threshold.
*
* Implementation of CLDR enhanced language matching:
* http://www.unicode.org/reports/tr35/tr35.html#EnhancedLanguageMatching
*
* @alpha
*/
export declare class LocaleMatcher {
private supported;
private count;
private default;
private exactMap;
constructor(supportedLocales: string | string[]);
/**
* Find the desired locale that is the closed match to a supported locale, within
* the given threshold. Any matches whose distance is greater than or equal to the
* threshold will be treated as having maximum distance.
*/
match(desiredLocales: string | string[], threshold?: number): LocaleMatch;
}