@evokegroup/locale
v2.0.0
Published
Parse language, country, and locale codes.
Downloads
1
Keywords
Readme
@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'
}
} */