browser-langs
TypeScript icon, indicating that this package has built-in type declarations

1.0.11 • Public • Published

Browser Langs

What's inside?

BCP47 defines standard for language codes that browser should use. Specification is quite wide but we will use most common setup which is used today:

<2 letter ISO 639>
// e.g. "no", "ca", "nl"

or

<2 letter ISO 639>-<ISO 3166-1>
// e.g. "es-mx", "ar-sa", "nl-be"

Installation

npm i browser-langs
# or
yarn add browser-langs

Documentation

import { all, find } from 'browser-langs';

// get list of all cultural (and not only) language codes
all() // list of `Language` objects returned

// find language matching language code
find('en') // English Language object will be returned
find('en-gb') // English (United Kingdom) Language object will be returned

// detect currently selected language in browser
detect() // current (most matching) Language object will be returned

// detect currently selected languages in browser (based on priority)
detectAll() // returns list of current Language objects

Credits

License

Please see LICENSE.txt

Author

Boostcom

Boostcom - we provide the most powerful management- and loyalty platform built for the needs of shopping centres.

Readme

Keywords

none

Package Sidebar

Install

npm i browser-langs

Weekly Downloads

7

Version

1.0.11

License

MIT

Unpacked Size

149 kB

Total Files

31

Last publish

Collaborators

  • boostcom