UNPKG

@aleksejdix/ally-bcp47

Version:

TypeScript package for working with BCP-47 language tags

38 lines (37 loc) 1.36 kB
import { LanguageTag, ValidationOptions, ValidationResult } from "../types/index.js"; /** * Validates a language tag against the BCP-47 specification * * @param tag The language tag to validate * @param options Validation options * @returns Validation result */ export declare function validateLanguageTag(tag: string, options?: ValidationOptions): ValidationResult; /** * Checks if a language tag is well-formed according to BCP-47 syntax rules * * @param tag The language tag to check * @returns True if the tag is well-formed, false otherwise */ export declare function isWellFormed(tag: string): boolean; /** * Checks if a language tag is valid (well-formed and all subtags exist in registry) * * @param tag The language tag to check * @returns True if the tag is valid, false otherwise */ export declare function isValid(tag: string): boolean; /** * Parses a language tag string into its component parts without validation * * @param tag The language tag to parse * @returns The parsed language tag or null if parsing fails */ export declare function parseTag(tag: string): LanguageTag | null; /** * 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;