@aleksejdix/ally-bcp47
Version:
TypeScript package for working with BCP-47 language tags
41 lines (40 loc) • 1.29 kB
TypeScript
/**
* BCP-47 Language Tag Validation Library
*
* A library for validating, parsing, and working with BCP-47 language tags
* according to RFC 5646.
*/
export * from "./types/index.js";
export { validateLanguageTag, isWellFormed, isValid, parseTag, canonicalizeTag, } from "./validators/validator.js";
export declare const VERSION = "1.1.0";
/**
* A TypeScript package for working with BCP-47 language tags
*/
/**
* Validates if a string is a valid BCP-47 language tag
*
* @param tag The language tag to validate
* @returns Boolean indicating if the tag is valid
*/
export declare function isValidLanguageTag(tag: string): boolean;
/**
* Parses a BCP-47 language tag into its components
*
* @param tag The language tag to parse
* @returns An object containing the tag components
*/
export declare function parseLanguageTag(tag: string): {
language?: string;
script?: string;
region?: string;
variant?: string[];
extension?: string[];
};
/**
* Gets the display name of a language tag in a specific locale
*
* @param tag The language tag
* @param displayLocale The locale to display the name in (defaults to 'en')
* @returns The display name of the language
*/
export declare function getLanguageDisplayName(tag: string, displayLocale?: string): string;