1.0.0 • Published 4 years ago

@houlagins/locale v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

sidebarDepth: 2

Locale Service

Description

Resolves the Locale from as a lowercase 2 letter code:

  1. HTML 5 Locale
<html lang="en"> 
  1. Legacy HTML meta tag
<meta http-equiv="content-language" content="en">
  1. Legacy Browsers
navigator.languages[0] || navigator.userLanguage || navigator.language || navigator.browserLanguage 
  1. Browser
(new Intl.NumberFormat()).resolvedOptions().locale

Install

yarn add @houlagins/locale

#OR 

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.

//[ 'ar', 'en', 'es', 'fr', 'ru', 'zh' ]
import { getUnLocale } from '@houlagins/locale'

const locale = getUnLocale()

console.log(locale)