UNPKG

@aleksejdix/ally-bcp47

Version:

TypeScript package for working with BCP-47 language tags

65 lines (64 loc) 2.33 kB
/** * ISO 15924 script codes registry * This file contains data for validating script subtags against the official registry */ /** * Map of valid ISO 15924 script codes * Key: script code, Value: script name */ export declare const ISO_15924_SCRIPTS: Record<string, string>; /** * Map of deprecated script codes to their preferred values */ export declare const SCRIPT_PREFERRED_VALUES: Record<string, string>; /** * Map of language subtags that have a default script * that should be suppressed in canonical form * Based on RFC 5646 Section 4.1 */ export declare const LANGUAGE_SUPPRESS_SCRIPT: Record<string, string>; /** * Checks if a script code is valid according to ISO 15924 * * @param code The script code to validate * @returns True if the code is valid, false otherwise */ export declare function isValidScriptCode(code: string): boolean; /** * Returns the canonical form of a script code (title case) * * @param code The script code to normalize * @returns The normalized script code */ export declare function normalizeScriptCode(code: string): string; /** * Checks if a script code has a preferred value in the registry * * @param code The script code to check * @returns True if the code has a preferred value, false otherwise */ export declare function hasPreferredScriptValue(code: string): boolean; /** * Gets the preferred value for a script code * * @param code The script code to get the preferred value for * @returns The preferred value or the original code if no preferred value exists */ export declare function getScriptPreferredValue(code: string): string; /** * Gets the default script for a language subtag that should be suppressed * in canonical form * * @param language The language subtag to get the suppress script for * @returns The script that should be suppressed or undefined if not applicable */ export declare function getLanguageSubtagSuppressScript(language: string): string | undefined; /** * Checks if a script subtag is redundant for a given language * A script is redundant if it's the default script for the language * * @param language The language subtag * @param script The script subtag * @returns True if the script is redundant, false otherwise */ export declare function hasRedundantScript(language: string, script: string): boolean;