@lengoo/locales-normalizer
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

Overview

Node.js Package

Small package to normalize locales across different standards.

Installation

npm install --save locales-normalizer

Usage

The normalizer has two methods, normalize() and getLanguage():

  • normalize() receives the language code and returns a normal version (e.g. en_US -> en-US)
  • getLanguage() receives the language code and returns some extra information about the language.

Example

const localeNormalizer = require('locales-normalizer');

const locale = 'en_US'; // Coming from PHP-ICU.

console.log(localeNormalizer.normalize(locale)); // output: en-US

console.log(localeNormalizer.getLanguage(locale)); 
/**
 * Output:
 * {
 *  code: 'en-US',
 *  locale: 'en',
 *  territory: 'US'
 * }
*/

Readme

Keywords

none

Package Sidebar

Install

npm i @lengoo/locales-normalizer

Weekly Downloads

0

Version

2.0.2

License

MIT

Unpacked Size

248 kB

Total Files

13

Last publish

Collaborators

  • belzee92
  • bretanac.93
  • daemyn
  • dejimenez
  • lengoo_npm
  • mpedroc90
  • rodrigoterminus