Query any country's spoken languages or countries where a language is spoken.
Installations
npm install @ladjs/country-language
Developer Guide
Typescript
No
Module System
CommonJS
Min. Node Version
>= 14
Node Version
16.18.1
NPM Version
8.19.2
Score
99.7
Supply Chain
100
Quality
81.3
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (99.41%)
Shell (0.59%)
Developer
ladjs
Download Statistics
Total Downloads
16,507,523
Last Day
25,588
Last Week
119,192
Last Month
521,610
Last Year
7,660,860
GitHub Statistics
16 Stars
51 Commits
5 Forks
2 Watching
2 Branches
10 Contributors
Bundle Size
130.61 kB
Minified
25.57 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.3
Package Id
@ladjs/country-language@1.0.3
Unpacked Size
242.49 kB
Size
31.09 kB
File Count
5
NPM Version
8.19.2
Node Version
16.18.1
Total Downloads
Cumulative downloads
Total Downloads
16,507,523
Last day
-6.6%
25,588
Compared to previous day
Last week
-16%
119,192
Compared to previous week
Last month
5.6%
521,610
Compared to previous month
Last year
58.1%
7,660,860
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
@ladjs/country-language
Maintained fork of country-language with zero-dependencies. Query any country's spoken languages or countries where a language is spoken.
Table of Contents
- Install
- Usage
- .getLanguageCodes (languageCodeType, cb)
- .getCountryCodes (countryCodeType, cb)
- .languageCodeExists (languageCode)
- .countryCodeExists (countryCode)
- .getCountry (code, cb)
- .getLanguage (code, cb)
- .getCountryLanguages (code, cb)
- .getLanguageCountries (code, cb)
- .getCountryMsLocales (code, cb)
- .getLanguageMsLocales (code, cb)
- .getCountries ()
- .getLanguages ()
- .getLanguageFamilies ()
- .getLocales (mode)
- .getLanguageFamilyMembers (family, cb)
- Contributors
- License
Install
npm:
1npm install @ladjs/country-language
Usage
Once you require @ladjs/country-language
, the following API will be available.
1const CountryLanguage = require('@ladjs/country-language');
.getLanguageCodes (languageCodeType, cb)
- @param {String} language code type. Acceptable values: 1, 2 or 3.
- @param {Function} callback on complete or error
- @cb {Error|null} if error
- @cb {Object} array String with language codes
Acceptable language code type parameter values: 1, 2, 3 for returning ISO-639-1, ISO-639-2, ISO-639-3 codes respectively. If not provided, ISO-639-1 codes will be returned.
1const allLanguageCodes = CountryLanguage.getLanguageCodes(2);
.getCountryCodes (countryCodeType, cb)
- @param {String} country code type. Acceptable values: 1, 2 or 3.
- @param {Function} callback on complete or error
- @cb {Error|null} if error
- @cb {Object} array String with country codes
Acceptable country code type parameter values: 1, 2, 3 for returning numerical code, alpha-2, alpha-3 codes respectively. If not provided, alpha-2 codes will be returned.
1const allCountryCodes = CountryLanguage.getCountryCodes(2);
.languageCodeExists (languageCode)
- @param {String} language code to check.
Returns Boolean indicating language existance. Language code parameter can be either a ISO-639-1, ISO-639-2 or ISO-639-3 code.
1const languageExists = CountryLanguage.languageCodeExists('en');
.countryCodeExists (countryCode)
- @param {String} country code to check.
Returns Boolean indicating country existance. Country code parameter can be either an alpha-2, alpha-3 or numerical code.
1const countryExists = CountryLanguage.countryCodeExists('GB');
.getCountry (code, cb)
- @param {String} country code
- @param {Function} callback on complete or error
- @cb {Error|null} if error
- @cb {Object} object containing country info
Country code can be either an Alpha-2 or Alpha-3 code. The returned object includes the following info:
code_2
: Country alpha-2 code (2 letters)code_3
: Country alpha-3 code (3 letters)numCode
: Country numeric codename
: Country namelanguages
: Array of language objects for each language spoken in the countrylangCultureMs
: Array of language cultures for the country supported by Microsoft©
Each language object in languages
property includes the following info:
iso639_1
: language iso639-1 code (2 letters)iso639_2
: language iso639-2 code (3 letters)iso639_2en
: language iso639-2 code with some codes derived from English names rather than native names of languages (3 letters)iso639_3
: language iso639-3 code (3 letters)name
: String array with one or more language names (in English)nativeName
: String array with one or more language names (in native language)direction
: Language script direction (either "LTR" or "RTL") - Left-to-Right, Right-to-Leftfamily
: language familycountries
: Array of country objects where this language is spoken
Each Microsoft© language culture object in langCultureMs
property icludes the following info:
langCultureName
: language culture namedisplayName
: language culture dispaly namecultureCode
: language culture code
1CountryLanguage.getCountry('GB', function (err, country) { 2 if (err) { 3 console.log(err); 4 } else { 5 const languagesInGB = country.languages; 6 } 7});
.getLanguage (code, cb)
- @param {String} language code
- @param {Function} callback on complete or error
- @cb {Error|null} if error
- @cb {Object} object containing language info
Language code can be either iso639-1, iso639-2, iso639-2en or iso639-3 code.
Contents of the returned language object are described in .getCountry
method.
1CountryLanguage.getLanguage('en', function (err, language) {
2 if (err) {
3 console.log(err);
4 } else {
5 const countriesSpeakingEN = language.countries;
6 }
7});
.getCountryLanguages (code, cb)
- @param {String} country code
- @param {Function} callback on complete or error
- @cb {Error|null} if error
- @cb {Object} object array containing country languages info
Country code can be either an Alpha-2 or Alpha-3 code. Each language object contains the following info:
iso639_1
: language iso639-1 code (2 letters)iso639_2
: language iso639-2 code with some codes derived from English names rather than native names of languages (3 letters)iso639_3
: language iso639-3 code (3 letters)
1CountryLanguage.getCountryLanguages('GB', function (err, languages) { 2 if (err) { 3 console.log(err); 4 } else { 5 languages.forEach(function (languageCodes) { 6 console.log(languageCodes.iso639_1); 7 }); 8 } 9});
.getLanguageCountries (code, cb)
- @param {String} language code
- @param {Function} callback on complete or error
- @cb {Error|null} if error
- @cb {Object} object array containing country info
Language code can be either iso639-1, iso639-2, iso639-2en or iso639-3 code. Each Country object contains the following info:
code_2
: Country alpha-2 code (2 letters)code_3
: Country alpha-3 code (3 letters)numCode
: Country numeric code
1CountryLanguage.getLanguageCountries('en', function (err, countries) { 2 if (err) { 3 console.log(err); 4 } else { 5 countries.forEach(function (countryCodes) { 6 console.log(countryCodes.code_3); 7 }); 8 } 9});
.getCountryMsLocales (code, cb)
- @param {String} country code
- @param {Function} callback on complete or error
- @cb {Error|null} if error
- @cb {Object} object array containing Language Cultures info for the country
Country code can be either an Alpha-2 or Alpha-3 code.
Contents of each Language Culture object are described in .getCountry
method.
1CountryLanguage.getCountryMsLocales('GB', function (err, locales) { 2 if (err) { 3 console.log(err); 4 } else { 5 locales.forEach(function (locale) { 6 console.log(locale.langCultureName); 7 }); 8 } 9});
.getLanguageMsLocales (code, cb)
- @param {String} language code
- @param {Function} callback on complete or error
- @cb {Error|null} if error
- @cb {Object} object array containing Language Cultures info for the language
Language code can be either iso639-1, iso639-2, iso639-2en or iso639-3 code.
Contents of each Language Culture object are described in .getCountry
method.
1CountryLanguage.getLanguageMsLocales('en', function (err, locales) { 2 if (err) { 3 console.log(err); 4 } else { 5 locales.forEach(function (locale) { 6 console.log(locale.langCultureName); 7 }); 8 } 9});
.getCountries ()
Returns an array object with info for every country in the world having an ISO 3166 code.
Contents of each country object in the array is described in .getCountry
method.
1const allCountries = CountryLanguage.getCountries();
.getLanguages ()
Returns an array object with info for every language in the world having an ISO 639-2 code (and a few more).
Contents of each language object in the array is described in .getCountry
method.
1const allLanguages = CountryLanguage.getLanguages();
.getLanguageFamilies ()
Returns an array of strings with the names of each language family.
1const allLanguageFamilies = CountryLanguage.getLanguageFamilies();
.getLocales (mode)
- @param {Boolean} locale symbols mode
Returns an array of strings with all locale codes. If mode ommited or false, locales with 3 parts will be returned like: az-Cyrl-AZ
1const localesSymbols = CountryLanguage.getLocales();
If mode is set to true, they will be returned like: az-AZ-Cyrl
1const localesSymbols = CountryLanguage.getLocales(true);
.getLanguageFamilyMembers (family, cb)
Returns an array object with info for every language in the world having an ISO 639-2 code (and a few more).
Contents of each language object in the array is described in .getCountry
method.
- @param {String} language family name (
- @param {Function} callback on complete or error
- @cb {Error|null} if error
- @cb {Object} object array containing languages info for each language member in the family.
Contents of the returned language object are described in .getCountry
method.
1CountryLanguage.getLanguageFamilyMembers('Indo-European', function (err, languages) { 2 if (err) { 3 console.log(err); 4 } else { 5 languages.forEach(function (language) { 6 console.log(language.name); 7 }); 8 } 9});
## Notes
For the following methods:
- .getLanguageCodes
- .getCountryCodes
- .getCountry
- .getLanguage
- .getCountryLanguages
- .getLanguageCountries
- .getCountryMsLocales
- .getLanguageMsLocales
- .getLanguageFamilyMembers
the cb
parameter is optional. When not provided, each method returns either an Object when there is no error, or a String in case of an error.
Any input parameter (country code, language code, language family name) is case insensitive.
Language#nativeName
string is not displayed correclty on the console for Right-to-Left (RTL) languages. However, there is no issue on string rendering (either on the browser or any text editor).
Contributors
Name |
---|
titanism |
License
MIT © Tassos Diamantidis
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 existing vulnerabilities detected
Reason
security policy file detected
Details
- Info: security policy file detected: github.com/ladjs/.github/SECURITY.md:1
- Info: Found linked content: github.com/ladjs/.github/SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: github.com/ladjs/.github/SECURITY.md:1
- Info: Found text in security policy: github.com/ladjs/.github/SECURITY.md:1
Reason
Found 2/28 approved changesets -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Info: no jobLevel write permissions found
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/ladjs/country-language/ci.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/ci.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/ladjs/country-language/ci.yml/master?enable=pin
- Warn: npmCommand not pinned by hash: .github/workflows/ci.yml:25
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 1 npmCommand dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 4 are checked with a SAST tool
Score
4.1
/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