Gathering detailed insights and metrics for country-language-lodash
Gathering detailed insights and metrics for country-language-lodash
npm install country-language-lodash
Typescript
Module System
Min. Node Version
Total Downloads
9,376
Last Day
25
Last Week
112
Last Month
570
Last Year
7,473
Minified
Minified + Gzipped
Latest Version
0.1.9
Package Id
country-language-lodash@0.1.9
Unpacked Size
248.60 kB
Size
32.99 kB
File Count
12
Cumulative downloads
Total Downloads
Last day
25%
25
Compared to previous day
Last week
-28.7%
112
Compared to previous week
Last month
55.3%
570
Compared to previous month
Last year
711.4%
7,473
Compared to previous year
1
Query any country's spoken languages or countries where a language is spoken. Forked to use lodash instead of underscore.
country-language
is available on npm.
$ npm install country-language
Once you require country-language
, the following API will be available.
1var CountryLanguage = require("country-language");
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.
1var allLanguageCodes = CountryLanguage.getLanguageCodes(2);
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.
1var allCountryCodes = CountryLanguage.getCountryCodes(2);
Returns Boolean indicating language existance. Language code parameter can be either a ISO-639-1, ISO-639-2 or ISO-639-3 code.
1var languageExists = CountryLanguage.languageCodeExists("en");
Returns Boolean indicating country existance. Country code parameter can be either an alpha-2, alpha-3 or numerical code.
1var countryExists = CountryLanguage.countryCodeExists("GB");
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 spokenEach Microsoft© language culture object in langCultureMs
property icludes the following info:
langCultureName
: language culture namedisplayName
: language culture dispaly namecultureCode
: language culture code1CountryLanguage.getCountry("GB", function (err, country) { 2 if (err) { 3 console.log(err); 4 } else { 5 var languagesInGB = country.languages; 6 } 7});
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 var countriesSpeakingEN = language.countries; 6 } 7});
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});
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 code1CountryLanguage.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});
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});
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});
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.
1var allCountries = CountryLanguage.getCountries();
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.
1var allLanguages = CountryLanguage.getLanguages();
Returns an array of strings with the names of each language family.
1var allLanguageFamilies = CountryLanguage.getLanguageFamilies();
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
If mode is set to true, they will be returned like: az-AZ-Cyrl
1var localesSymbols = CountryLanguage.getLocales(); 2var localesSymbols = CountryLanguage.getLocales(true);
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.
Contents of the returned language object are described in .getCountry
method.
1CountryLanguage.getLanguageFamilyMembers( 2 "Indo-European", 3 function (err, languages) { 4 if (err) { 5 console.log(err); 6 } else { 7 languages.forEach(function (language) { 8 console.log(language.name); 9 }); 10 } 11 } 12);
For the following methods:
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).
Copyright (c) 2014 BDSwiss
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
No vulnerabilities found.
No security vulnerabilities found.