npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

countries-speaking-languages

v1.2.3

Published

Query country information to know if it has specific languages as official language or has specific language as current language

Downloads

5

Readme

Made by @Vic-rider

countries-speaking-languages, query country information to know if a language is speaking in this country as official language or a native language.

Install

Install using npm install countries-speaking-languages

Usage

To include Countries-speaking-languages, require or import it:

in JavaScript

CountriesSpeakingLanguage = require('countries-speaking-languages');

in TypeScript

import { CountriesSpeakingLanguage } from "countries-speaking-languages";

Create an instance of it

const countriesSpeakingLanguages = new CountriesSpeakingLanguage();

You can get country information.

Ex :

countriesSpeakingLanguages.getCountry('country_code');
// returns country_datas [object]

You can get country officials languages data.

Ex :

countriesSpeakingLanguages.getCountryOfficialsLanguages('BJ'); // "BJ" as `country_code`
// returns { 'languages' : ['French'], 'languages_codes': ['fr'] }

You can get country spoken languages data.

Ex :

countriesSpeakingLanguages.getCountryAllSpeakingLanguages('BJ'); // "BJ" as `country_code`
// returns [ { "language": "French", "code": "fr" }, { "language": "Yoruba", "code": "yo" }, { "language": "Fon", "code": "fon" } ]

Check if a specific language is spoken as official language in a specific country

Ex :

countriesSpeakingLanguages.hasLanguageAsOfficial('fr', 'JP'); // "JP" as `country_code` and 'fr' as `language_code`
// returns false    : french is not an official language of Japan

Check if a specific language is spoken in a specific country

Ex :

countriesSpeakingLanguages.hasLanguage('pt', 'AO'); // "AO" as `country_code` and 'pt' as `language_code`
// returns true  : portuguese is spoken in Angola

You also have others ways to check if some languages are spoken in a specific country as official languages.

Ex :

countriesSpeakingLanguages.hasEnglishAsOfficialLanguage('AO'); // "AO" as `country_code` `
// returns false  : english is not spoken in Angola as official language

Here is other Official languages checker you can use:

  • hasMadarinAsOfficialLanguage(country_code)
  • hasHindiAsOfficialLanguage(country_code)
  • hasSpanishAsOfficialLanguage(country_code)
  • hasFrenchAsOfficialLanguage(country_code)
  • hasArabicAsOfficialLanguage(country_code)
  • hasBengaliAsOfficialLanguage(country_code)
  • hasRussianAsOfficialLanguage(country_code)
  • hasPortugueseAsOfficialLanguage(country_code)
  • hasIndonesianAsOfficialLanguage(country_code)
  • hasUrduOfficiaAslLanguage(country_code)
  • hasJapaneseAsOfficialLanguage(country_code)
  • hasGermanAsOfficialLanguage(country_code)
  • hasChineseAsOfficialLanguage(country_code)
  • hasTurkishAsOfficialLanguage(country_code)
  • hasKoreanAsOfficialLanguage(country_code)
  • hasYorubaAsOfficialLanguage(country_code)
  • hasFonAsOfficialLanguage(country_code)

Here is the ways to check if some languages are spoken in a specific country.

Ex :

countriesSpeakingLanguages.hasEnglishAsSpeakingLanguages('GH'); // "GH" as `country_code` `
// returns true  : english is spoken in Ghana

Here is other languages checker you can use:

  • hasMadarinAsSpeakingLanguages(country_code)
  • hasHindiAsSpeakingLanguages(country_code)
  • hasSpanishAsSpeakingLanguages(country_code)
  • hasFrenchAsSpeakingLanguages(country_code)
  • hasArabicAsSpeakingLanguages(country_code)
  • hasBengaliAsSpeakingLanguages(country_code)
  • hasRussianAsSpeakingLanguages(country_code)
  • hasPortugueseAsSpeakingLanguages(country_code)
  • hasIndonesianAsSpeakingLanguages(country_code)
  • hasUrduSpeakingLanguage(country_code)
  • hasJapaneseAsSpeakingLanguages(country_code)
  • hasGermanAsSpeakingLanguages(country_code)
  • hasJavaneseAsSpeakingLanguages(country_code)
  • hasChineseAsSpeakingLanguages(country_code)
  • hasTurkishAsSpeakingLanguages(country_code)
  • hasKoreanAsSpeakingLanguages(country_code)
  • hasYorubaAsSpeakingLanguages(country_code)
  • hasFonAsSpeakingLanguages(country_code)

Test

To test countries-speaking-languages, run npm test