Installations
npm install @cospired/i18n-iso-languages
Developer Guide
Typescript
No
Module System
CommonJS, UMD
Min. Node Version
^12.22.0 || ^14.17.0 || >=16.0.0
Node Version
18.7.0
NPM Version
8.15.0
Score
97.7
Supply Chain
99.6
Quality
78.3
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Languages
JavaScript (100%)
Developer
cospired
Download Statistics
Total Downloads
3,267,996
Last Day
3,890
Last Week
18,501
Last Month
82,613
Last Year
970,197
GitHub Statistics
53 Stars
196 Commits
31 Forks
5 Watching
3 Branches
17 Contributors
Bundle Size
7.85 kB
Minified
2.35 kB
Minified + Gzipped
Package Meta Information
Latest Version
4.2.0
Package Id
@cospired/i18n-iso-languages@4.2.0
Unpacked Size
224.07 kB
Size
54.85 kB
File Count
52
NPM Version
8.15.0
Node Version
18.7.0
Publised On
28 Jan 2024
Total Downloads
Cumulative downloads
Total Downloads
3,267,996
Last day
-16%
3,890
Compared to previous day
Last week
-20.6%
18,501
Compared to previous week
Last month
9.1%
82,613
Compared to previous month
Last year
-6.1%
970,197
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
i18n-iso-languages
i18n for ISO 639 language codes. We support Alpha-2, Alpha-3 B and T codes from https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
This packages is heavily based on i18n-iso-countries.
We intent to keep the interface of i18n-iso-languages as close as possible to i18n-iso-countries.
Installing
Install it using npm: npm install @cospired/i18n-iso-languages
If used in a browser environment, you will need to manually install the local you wish to support.
1var languages = require("@cospired/i18n-iso-languages"); 2 3// Support german & english languages. 4languages.registerLocale(require("@cospired/i18n-iso-languages/langs/en.json")); 5languages.registerLocale(require("@cospired/i18n-iso-languages/langs/de.json"));
Code to Language
Get the name of a language by it's ISO 639-1 (Alpha-2), ISO 639-2/T or B (Alpha-3) code
1var languages = require("@cospired/i18n-iso-languages"); 2console.log("de (639-1/Alpha-2) => " + languages.getName("de", "en")); // German 3console.log("en (639-1/Alpha-2) => " + languages.getName("de", "de")); // Deutsch 4console.log("de (639-2T/Alpha-3) => " + languages.getName("deu", "en")); // German 5console.log("de (639-2B/Alpha-3) => " + languages.getName("ger", "en")); // German
Get all names by their ISO 639-1 code
1var languages = require("@cospired/i18n-iso-languages"); 2console.log(languages.getNames("en")); // { 'ab': 'Abkhazian', 'aa': 'Afar', [...], 'za': 'Zhuang', 'zu': 'Zulu' }
Supported languages (ISO 639-1)
ar
: Arabic (based on https://github.com/umpirsky/language-list/blob/master/data/ar/language.json)bg
: Bulgarian (based on https://bg.wikipedia.org/wiki/Кодове_на_езици with minor adjustments)br
: Breton (based on https://br.wikipedia.org/wiki/Listenn_glok_kodoù_ISO_639-1)cs
: Czech (based on https://cs.wikipedia.org/wiki/Seznam_kódů_ISO_639-1)da
: Danish (based on https://da.wikipedia.org/wiki/ISO_639-1)de
: German (by native speaker)en
: English (ISO 639-1 standard names)es
: Spanish (based on https://es.wikipedia.org/wiki/ISO_639-1)fi
: Finnish (based on https://kotoistus.fi/suositukset/suositukset-kielet-fi-koodi/)fr
: French (based on https://fr.wikipedia.org/wiki/Liste_des_codes_ISO_639-1)he
: Hebrew (based on ECMAScript Internationalization API data)hu
: Hungarian (based on https://hu.wikipedia.org/wiki/ISO_639-1_nyelvkódok_listája)id
: Indonesian (based on https://github.com/umpirsky/language-list/blob/master/data/id/language.json)is
: Islandic (based on https://is.wikipedia.org/wiki/Listi_yfir_tungumálakóða_%C3%AD_ISO_639-1)it
: Italian (based on https://github.com/umpirsky/language-list/blob/master/data/it/language.json)ja
: Japanese (by professional translator)ko
: Korean (based on https://github.com/umpirsky/language-list/blob/master/data/ko/language.json)lt
: Lithuanian (based on https://lt.wikipedia.org/wiki/Sąrašas:ISO_639-1_kodai)lv
: Latvian (based on https://lv.wikipedia.org/wiki/ISO_639-1_kodu_saraksts)ms
: Malay (based on https://github.com/umpirsky/language-list/blob/master/data/ms/language.json)nl
: Dutch (based on https://nl.wikipedia.org/wiki/Lijst_van_ISO_639-codes)no
: Norwegian (based on https://no.wikipedia.org/wiki/Liste_over_ISO_639-1-koder)pl
: Polish (based on https://pl.wiktionary.org/wiki/Wikis%C5%82ownik:Kody_j%C4%99zyk%C3%B3w)pt
: Portuguese (European) (based on https://pt.wikipedia.org/wiki/ISO_639)ro
: Romanian (based on https://ro.wikipedia.org/wiki/Lista_codurilor_ISO_639-1)ru
: Russian (by professional translator)sk
: Slovak (based on https://sk.wikipedia.org/wiki/ISO_639)sv
: Swedish (based on https://sv.wikipedia.org/wiki/ISO_639)th
: Thai (based on https://github.com/umpirsky/language-list/blob/master/data/th/language.json)uk
: Ukrainian (based on https://uk.wikipedia.org/wiki/Список_мовних_кодів_ISO_639)vi
: Vietnamese (based on https://github.com/umpirsky/language-list/blob/master/data/vi/language.json)zh
: Chinese (by professional translator)
Language to Code
1var languages = require("@cospired/i18n-iso-languages"); 2console.log("German => " + languages.getAlpha2Code('German', 'en')); 3// German => de 4 5console.log("German => " + languages.getAlpha3TCode('German', 'en')); 6// German => deu 7 8console.log("German => " + languages.getAlpha3BCode('German', 'en')); 9// German => ger
Codes
Convert ISO 639-2 (Alpha-3) to ISO 639-1 (Alpha-2) code
1var languages = require("@cospired/i18n-iso-languages"); 2console.log("deu (Alpha-3) => " + languages.alpha3ToAlpha2("deu") + " (Alpha-2)"); 3// deu (Alpha-3 T) => de (Alpha-2) 4 5var languages = require("@cospired/i18n-iso-languages"); 6console.log("ger (Alpha-3 B) => " + languages.alpha3ToAlpha2("ger") + " (Alpha-2)"); 7// ger (Alpha-3 B) => de (Alpha-2)
Convert ISO 639-1 (Alpha-2) to ISO 639-2 (Alpha-3) code
1var languages = require("@cospired/i18n-iso-languages"); 2console.log("de (Alpha-2) => " + languages.alpha2ToAlpha3T("de") + " (Alpha-3 T)"); 3// de (Alpha-2) => deu (Alpha-3 T) 4 5var languages = require("@cospired/i18n-iso-languages"); 6console.log("de (Alpha-2) => " + languages.alpha2ToAlpha3B("de") + " (Alpha-3 B)"); 7// de (Alpha-2) => ger (Alpha-3 B)
Get all ISO 639-1 (Alpha-2) codes
1var languages = require("@cospired/i18n-iso-languages"); 2console.log(languages.getAlpha2Codes()); 3// { 'aa': 'aar', 'ab': 'abk', [...], 'za': 'zha', 'zu': 'zul' }
Get all ISO 639-2 (Alpha-3) codes
1var languages = require("@cospired/i18n-iso-languages"); 2console.log(languages.getAlpha3TCodes()); 3// { 'aar': 'aa', 'abk': 'ab', [...], 'zha': 'za', 'zul': 'zu' } 4 5var languages = require("@cospired/i18n-iso-languages"); 6console.log(languages.getAlpha3BCodes()); 7// { 'aar': 'aa', 'abk': 'ab', [...], 'zha': 'za', 'zul': 'zu' }
Validate language code
1var languages = require("@cospired/i18n-iso-languages"); 2console.log(languages.isValid("de"), languages.isValid("ger"), languages.isValid("xx"))); 3// true, true, false
Contribution
To add a language:
- add a json file under langs/ (in alphabetical order)
- add the language to the
data
object in enty-node.js at the top (in alphabetical order) - add language to section Supported languages in README.md (in alphabetical order)
- add language to keywords in package.json (in alphabetical order)
- add language to the "unreleased" section of the changelog
- run
npm install && make test
to make sure that tests are passing - open a PR on GitHub
Please do not change the version in package.json, package-lock.json or changelog.md.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 4/12 approved changesets -- score normalized to 3
Reason
9 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-pfrx-2q88-qq97
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-x3m3-4wpv-5vgc
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-7p7h-4mm5-852v
- Warn: Project is vulnerable to: GHSA-g3ch-rx76-35fx
Reason
0 commit(s) and 1 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 24 are checked with a SAST tool
Score
2.6
/10
Last Scanned on 2025-01-27
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More