1.0.14 • Published 3 months ago

all-iso-language-codes v1.0.14

Weekly downloads
-
License
MIT
Repository
-
Last release
3 months ago

List of ISO 639-1, 639-2T, 639-2B and 639-3 codes with translations in all available languages

Sometimes you need to get a fresh list of 639-1, 639-2T, 639-2B or 639-3 language codes and their translations. Until now there was not an easy way to get them.

All data are available in json format in data/[language]/639-1.json. More formats might be available in the future.

Usage

1) JS functions (with TS type definitions included) 2) Directly, using files located in data folder

JS functions

FunctionArgumentsReturn valueExample usage
getEnglishName(code: string)language codestring | nullgetEnglishName('cs') => Czech
getNativeName(code: string)language codestring | nullgetNativeName('cs') => čeština
getName(code: string, language = 'en')from language, to language?string | nullgetName('cs', 'en') => Czech
isValid(code: string, availableIsoTypes?: IsoType[], moreInfo = false)language code, IsoType (below table), moreInfoboolean | { 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[] | nullgetIsoCodesFromNativeName('Č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'

File format

If you have some ideas (csv, another JSON format...) let me know or create PR.

Adding more languages

Language matrix is generated by Node.js Intl API (version 21.3.0). If you would like to edit something, Create PR in Node.js Intl API. Wait until release and run yarn generate.

Tests

There are jest tests which tests basic functionality. Feel free to extend them or convert to vitest.

More info

Getting the list of all available languages is from official list

More packages from me

  • all-iso-language-codes - List of ISO 639-1, 639-2T, 639-2B and 639-3 codes with translations in all available languages
  • expo-video-player - Customizable Video Player controls for Expo
  • free-email-domains-list - Fresh list of all free email domain providers. Can be used to check if an email address belongs to a company. Updated weekly
1.0.14

3 months ago

1.0.13

5 months ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.5

2 years ago

1.0.10

1 year ago

1.0.2

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago

1.0.0-alpha.0

2 years ago