bcp47-helper
Version:
A lightweight TypeScript library for parsing, validating, and managing BCP 47 language tags in Node.js and browser environments.
36 lines (35 loc) • 1.07 kB
TypeScript
export type LangInfo = {
code: string;
fullName: string;
language: string;
region: string;
description: string;
};
/**
* Normalize and map array of codes to full names
*/
export declare function mapLanguages(codes: string[]): Record<string, string>;
/**
* Get language info by code
*/
export declare function getLanguageInfo(code: string): LangInfo | null;
/**
* Get all language variants from a base language code
*/
export declare function getAvailableVariants(baseLangs: string[] | string): Record<string, string>;
/**
* ✅ NEW: Return all codes with their full names
*/
export declare function listAllLanguages(): Record<string, string>;
/**
* ✅ NEW: Search by full name, region or language (case-insensitive)
*/
export declare function searchByName(term: string): Record<string, string>;
/**
* ✅ NEW: Group language codes under base language
*/
export declare function groupByLanguage(): Record<string, string[]>;
/**
* ✅ NEW: Validate if a code exists in dataset
*/
export declare function validateCode(code: string): boolean;