How to know which languages are spoken in a country as official or native.

vicrider

Vic-rider

Posted on July 15, 2023

How to know which languages are spoken in a country as official or native.

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');
Enter fullscreen mode Exit fullscreen mode

in TypeScript

import { CountriesSpeakingLanguage } from "countries-speaking-languages";
Enter fullscreen mode Exit fullscreen mode

Create an instance of it

const countriesSpeakingLanguages = new CountriesSpeakingLanguage();
Enter fullscreen mode Exit fullscreen mode

You can get country information.

Ex :

countriesSpeakingLanguages.getCountry('country_code');
// returns country_datas [object]
Enter fullscreen mode Exit fullscreen mode

You can get country officials languages data.

Ex :

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

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" } ]
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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

💖 💪 🙅 🚩
vicrider
Vic-rider

Posted on July 15, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related