List of all iso 639-1, 639-2T, 639-2B, 639-3 codes with their translations in any language
json format in data/[language]/639-1.json. More formats might be available in the future.
getEnglishName(code: string) | language code | string | null | getEnglishName('cs') => Czech |
getNativeName(code: string) | language code | string | null | getNativeName('cs') => čeština |
getName(code: string, language = 'en') | from language, to language? | string | null | getName('cs', 'en') => Czech |
isValid(code: string, availableIsoTypes?: IsoType[], moreInfo = false) | language code, IsoType (below table), moreInfo | boolean | { iso: IsoType | null; found: boolean; } | isValid('cs') => true, isValid('cs', ['639-1'], true) => { iso: '639-1'; found: true; }, |
getIsoCodesFromNativeName(nativeName: string, normalizeString = false) | language name, should normalize string (lowercase and remove diacritics) | IsoType[] | null | getIsoCodesFromNativeName('ČeŠtInA', true) => ['639-3', '639-2B', '639-2T', '639-1'] |
getAll639_1() | - | string[] (_639-1_ array) | getAll639_1() => ['aa', 'ab', 'af'...] |
getAll639_2B() | - | string[] (_639-2B_ array) | getAll639_2B() => ['aar', 'abk', 'ace'...] |
getAll639_2T() | - | string[] (_639-2T_ array) | getAll639_2T() => ['aar', 'abk', 'ace'...] |
getAll639_3() | - | string[] (_639-3_ array) | getAll639_3() => ['aaa', 'aab', 'aac'...] |
type IsoType = '639-1' | '639-2B' | '639-2T' | '639-3'
csv, another JSON format...) let me know or create PR.
Node.js Intl API (version 25.2.1). If you would like to edit something, Create PR in Node.js Intl API. Wait until release and run yarn generate.
data/patches/overrides.json file to override nativeName and englishName for specific languages. Example of the file:
json
{
"$schema": "./overrides.schema.json",
"$comment": "Patch file for overriding nativeName and englishName based on ISO 639-3 codes. Use 639-3 code as key.",
"eng": {
"nativeName": "English (Custom)",
"englishName": "English (Custom)"
},
"ces": {
"nativeName": "čeština (Vlastní)",
"englishName": "Czech (Custom)"
}
}
`
Tests
There are jest tests which tests basic functionality. Feel free to extend them or convert to vitest`.