@mapbox/locale-utils

0.0.6 • Public • Published

Locale Utils

A helper library for finding an appropriate locale from a list of available locales given an input locale.

Build Status

Installation

npm install @mapbox/locale-utils --save

Usage

var locale = require('@mapbox/locale-utils');

var availableLocales = [
    'en-US',
    'en-GB',
    'es-ES',
    'pt-PT',
    'tr',
    'zh-Hans'
];

// Find the best fitting locale given an input locale
var newLocale = locale.bestMatchingLocale('es-MX', availableLocales));
// Returns `es-ES` since `es-MX` is not an available locale.


// Parse a locale into smaller, easier to understand pieces.
var codedLocale = locale.parseLocaleIntoCodes('es-MX');
// Returns:
// {
//     locale: 'es-MX',
//     language: 'es',
//     script: undefined,
//     region: 'MX'
// }

Readme

Keywords

none

Package Sidebar

Install

npm i @mapbox/locale-utils

Weekly Downloads

310

Version

0.0.6

License

ISC

Unpacked Size

7.23 kB

Total Files

7

Last publish

Collaborators

  • mbx-npm-ci-production
  • mbx-npm-ci-staging
  • mbx-npm-advanced-actions-production
  • mbx-npm-advanced-actions-staging
  • mbx-npm-09-production
  • mbx-npm-08-production
  • mbx-npm-07-production
  • mbx-npm-06-production
  • mbx-npm-05-production
  • mbx-npm-04-production
  • mbx-npm-03-production
  • mbx-npm-02-production
  • mbx-npm-01-production
  • mbx-npm-02-staging
  • mapbox-npm-01
  • mapbox-npm-02
  • mapbox-npm-07
  • mapbox-npm-03
  • mapbox-npm-04
  • mapbox-npm-09
  • mapbox-npm-05
  • mapbox-npm-06
  • mapbox-npm-08
  • mapbox-npm-advanced-actions
  • mapbox-npm-ci
  • mapbox-npm
  • mapbox-admin
  • mapbox-machine-user