Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cldr-language-country

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cldr-language-country

A small utility to get CLDR, country code (cc) and language code (lc) data.

  • 0.5.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
23
decreased by-41.03%
Maintainers
1
Weekly downloads
 
Created
Source

cldr-language-country

Tiny util that maps 2-character language codes (lc) and country codes (cc) to CLDR locale data. Especially useful for generating search queries.

Install

npm i cldr-language-country

Usage

The API provides three main functions: generateData(), keyByCC(), and keyByLC().

generateData()
import { generateData } from 'cldr-language-country';

const locales = generateData();

Result:

[
    {
        language: {
            code: 'en',
            name: 'English',
            native: 'English'
        },
        country: {
            code: 'us',
            name: 'United States'
        },
        locale: 'en-US'
    } 
]
keyByCC()
import { keyByCC } from 'cldr-language-country';

const locales = keyByCC();

Result:

{
    'CA': [
        {
            language: {
                code: 'en',
                name: 'English',
                native: 'English'
            },
            country: {
                code: 'CA',
                name: 'Canada'
            },
            locale: 'en-CA'
        },
        {
            language: {
                code: 'fr',
                name: 'French',
                native: 'Français'
            },
            country: {
                code: 'CA',
                name: 'Canada'
            },
            locale: 'fr-CA' 
        }
    ]
}
keyByLC()
import { keyByLC } from 'cldr-language-country';

const locales = keyByLC();

Result:

{
    'en': [
        {
            language: {
                code: 'en',
                name: 'English',
                native: 'English'
            },
            country: {
                code: 'AE',
                name: 'United Arab Emirates'
            },
            locale: 'en-AE'
        },
        {
            language: {
                code: 'en',
                name: 'English',
                native: 'English'
            },
            country: {
                code: 'AG',
                name: 'Antigua and Barbuda'
            },
            locale: 'en-AG'
        },
        ...continued
    ]
}

Keywords

FAQs

Package last updated on 28 May 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc