Locale Service
Description
Resolves the Locale from as a lowercase 2 letter code:
- HTML 5 Locale
<html lang="en">
- Legacy HTML meta tag
<meta http-equiv="content-language" content="en">
- Legacy Browsers
navigator.languages[0] || navigator.userLanguage || navigator.language || navigator.browserLanguage
- Browser
(new Intl.NumberFormat()).resolvedOptions().locale
Install
yarn add @houlagins/locale
npm install @houlagins/locale
API
getLocale
import { getLocale } from '@houlagins/locale'
const locale = getLocale()
console.log(locale)
getUnLocale
Returns one of the 6 UN languages or default en.
import { getUnLocale } from '@houlagins/locale'
const locale = getUnLocale()
console.log(locale)