Security News
Introducing the Socket Python SDK
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
@ladjs/country-language
Advanced tools
Maintained fork of country-language with zero-dependencies. Query languages spoken to a country or countries where people speak a language.
Maintained fork of country-language with zero-dependencies. Query any country's spoken languages or countries where a language is spoken.
npm:
npm install @ladjs/country-language
Once you require @ladjs/country-language
, the following API will be available.
const CountryLanguage = require('@ladjs/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.
const 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.
const 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.
const languageExists = CountryLanguage.languageCodeExists('en');
Returns Boolean indicating country existance. Country code parameter can be either an alpha-2, alpha-3 or numerical code.
const 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 codeCountryLanguage.getCountry('GB', function (err, country) {
if (err) {
console.log(err);
} else {
const languagesInGB = country.languages;
}
});
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.
CountryLanguage.getLanguage('en', function (err, language) {
if (err) {
console.log(err);
} else {
const countriesSpeakingEN = language.countries;
}
});
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)CountryLanguage.getCountryLanguages('GB', function (err, languages) {
if (err) {
console.log(err);
} else {
languages.forEach(function (languageCodes) {
console.log(languageCodes.iso639_1);
});
}
});
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 codeCountryLanguage.getLanguageCountries('en', function (err, countries) {
if (err) {
console.log(err);
} else {
countries.forEach(function (countryCodes) {
console.log(countryCodes.code_3);
});
}
});
Country code can be either an Alpha-2 or Alpha-3 code.
Contents of each Language Culture object are described in .getCountry
method.
CountryLanguage.getCountryMsLocales('GB', function (err, locales) {
if (err) {
console.log(err);
} else {
locales.forEach(function (locale) {
console.log(locale.langCultureName);
});
}
});
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.
CountryLanguage.getLanguageMsLocales('en', function (err, locales) {
if (err) {
console.log(err);
} else {
locales.forEach(function (locale) {
console.log(locale.langCultureName);
});
}
});
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.
const 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.
const allLanguages = CountryLanguage.getLanguages();
Returns an array of strings with the names of each language family.
const 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
const localesSymbols = CountryLanguage.getLocales();
If mode is set to true, they will be returned like: az-AZ-Cyrl
const 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.
CountryLanguage.getLanguageFamilyMembers('Indo-European', function (err, languages) {
if (err) {
console.log(err);
} else {
languages.forEach(function (language) {
console.log(language.name);
});
}
});
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).
Name |
---|
titanism |
MIT © Tassos Diamantidis
FAQs
Maintained fork of country-language with zero-dependencies. Query languages spoken to a country or countries where people speak a language.
The npm package @ladjs/country-language receives a total of 153,798 weekly downloads. As such, @ladjs/country-language popularity was classified as popular.
We found that @ladjs/country-language demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.
Security News
A new Rust RFC proposes "Trusted Publishing" for Crates.io, introducing short-lived access tokens via OIDC to improve security and reduce risks associated with long-lived API tokens.