Meet npm Pro: unlimited public & private packages + package-based permissions.Learn more »

iso-lang-codes

2.0.0 • Public • Published

Build Status JavaScript Style Guide

ISO Language Codes

Node util for ISO Language Codes (639-1 and 693-2) and IETF Language Types

Created using the data from https://datahub.io/core/language-codes.

Use this util to get and validate the languages codes, countries and languages names.


Usage

Install the latest version:

npm i --save iso-lang-codes@latest

Require the module in your code & start using:

const codes = require('iso-lang-codes')

codes.validateLocaleCode('pt-PT')


Documentation

validateLocaleCode

Takes a locale code and checks if exists in the data dictionary

Parameters

  • localeCode string Language code (e.g. "en-GB")

Returns boolean

validateLanguageCode

Takes a language code and checks if exists in the data dictionary

Parameters

  • languageCode string Language code (e.g. "en")

Returns boolean

findCountryLanguages

Takes a country code and returns the list of languages valid for it

Parameters

  • countryCode string Country code (e.g. "PT")

Returns Array<string> Languages list

findCountryLocales

Takes a country code and returns the list of locales valid for it

Parameters

  • countryCode string Country code (e.g. "PT")

Returns Array<string> Locales list

locales

Returns a list with a map of all existing locale codes and the respective country+countryCode

Returns Object Locales list in the form of a map: ['pt-PT'] => 'Portuguese (PT)'

Install

npm i iso-lang-codes

DownloadsWeekly Downloads

160

Version

2.0.0

License

MIT

Unpacked Size

268 kB

Total Files

13

Last publish

Collaborators

  • avatar