@aleksejdix/ally-bcp47
Version:
TypeScript package for working with BCP-47 language tags
45 lines (44 loc) • 1.24 kB
TypeScript
/**
* Registry exports
* This file exports all registry-related functions and data
*/
export * from "./iso639.js";
export * from "./iso3166.js";
export * from "./iso15924.js";
/**
* Normalizes a BCP-47 language tag to canonical form
* implementing the canonicalization rules in RFC 5646 Section 4.5
*
* @param tag The language tag to normalize
* @returns The canonical form of the language tag
*/
export declare function normalizeTag(tag: string): string;
/**
* Canonicalizes a language tag to its canonical form
*
* @param tag The language tag to canonicalize
* @returns The canonicalized tag or null if the tag is invalid
*/
export declare function canonicalizeTag(tag: string): string | null;
/**
* Validates a tag against the registry
*
* @param tag The parsed language tag to validate
* @returns Validation problems found during registry validation
*/
export declare function validateTagAgainstRegistry(tag: {
language?: string;
script?: string;
region?: string;
extlang?: string[];
grandfathered?: boolean;
}): {
valid: boolean;
problems: {
type: string;
subtag: string;
subtagType: string;
message: string;
suggestedReplacement?: string;
}[];
};