Logo

dev-resources.site

for different kinds of informations.

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

Published at
7/15/2023
Categories
country
countries
languages
native
Author
vicrider
Author
8 person written this
vicrider
open
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

languages Article's
30 articles in total
Favicon
Odin's Elixir
Favicon
Automating Builds for Different Languages in Azure DevOps
Favicon
[15/52] The Three Languages an Engineer Needs To Know (or maybe it's more)
Favicon
Feedback : Using embedded python daily for more than 2 years
Favicon
How to actually choose which programming language to learn
Favicon
ChatGPT: “Per què és important que les intel·ligències artificials com jo entenguin i parlin català”
Favicon
Why do we have programming languages in the first place? Part 1
Favicon
Los Podcasts que te ayudarán a mejorar tu English Listening
Favicon
Herramientas super poderosas para aprender a pronunciar en Inglés
Favicon
Go(lang) to F*** yourself
Favicon
MiniScript Ports
Favicon
Herramientas que harán increíble a tu Ingles
Favicon
Python vs JavaScript — A Brief Overview
Favicon
Type Rules
Favicon
Type Declaration
Favicon
Coding Plane of Programming Languages and Programmers by AI
Favicon
A Retrospective on Error Management: Where Do We Go From Here?
Favicon
Which Programming Language is Best for Game Development?
Favicon
From Binary to Natural Language: The Transforming Landscape of Programming Languages
Favicon
I need help with my research 🙏🏻
Favicon
How to know which languages are spoken in a country as official or native.
Favicon
Why Choose R? Pros and Cons of this Programming Language
Favicon
Boolean coercion pitfalls (with examples)
Favicon
What If? We compare programming languages with Superheroes
Favicon
Here are the top 7 programming languages based on popularity and usage as of 2023:
Favicon
Why Every Programming Language is Terrible
Favicon
Hygiene is not just for macros
Favicon
Top 10 Most Popular Programming languages in 2023
Favicon
Non-English articles on DEV
Favicon
Raku on asdf

Featured ones: