@evokegroup/locale
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

@evokegroup/locale

Parse language, country, and locale codes.

Class: Locale

static country(code)

Parse a country or country code.

const Locale = require('@evokegroup/locale');
console.log(Locale.country('us')); // { code: 'us', name: 'United States' }
console.log(Locale.country('United States')); // { code: 'us', name: 'United States' }

static language(code)

Parse a language or language code.

const Locale = require('@evokegroup/locale');
console.log(Locale.language('en')); // { code: 'en', name: 'English' }
console.log(Locale.language('English')); // { code: 'en', name: 'English' }

static parse(code)

Parse a local code.

const Locale = require('@evokegroup/locale');
console.log(Locale.parse('en-US'));
/* {
  code: 'en-US',
  language: {
    code: 'en',
    name: 'English'
  },
  country: {
    code: 'US',
    name: 'United States'
  }
} */

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i @evokegroup/locale

    Weekly Downloads

    0

    Version

    2.0.0

    License

    ISC

    Unpacked Size

    23.6 kB

    Total Files

    5

    Last publish

    Collaborators

    • ybevoke
    • jtsuyuki
    • evokejames
    • evoke-cjamodeo