# browser-locale

> get the user's selected language locale from the navigator object from client-side js

Latest version **1.0.3** (published 2017-08-23) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install browser-locale
pnpm add browser-locale
yarn add browser-locale
bun add browser-locale
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2017-08-23 |
| First published | 2014-10-13 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 104 |
| Author | max ogden |
| Maintainers | zeke, maxogden |
| Keywords | locale, language |

## Links

- npm: https://www.npmjs.com/package/browser-locale
- Repository: https://github.com/maxogden/browser-locale
- Homepage: https://github.com/maxogden/browser-locale#readme
- Issues: https://github.com/maxogden/browser-locale/issues
- npm.io page: https://npm.io/package/browser-locale

## Alternatives

- [messageformat](https://npm.io/package/messageformat.md) — 329.7K weekly downloads
- [@mintlify/scraping](https://npm.io/package/@mintlify/scraping.md) — 294.8K weekly downloads
- [@mintlify/previewing](https://npm.io/package/@mintlify/previewing.md) — 209.5K weekly downloads
- [@mintlify/prebuild](https://npm.io/package/@mintlify/prebuild.md) — 209.5K weekly downloads
- [@mintlify/link-rot](https://npm.io/package/@mintlify/link-rot.md) — 206.3K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2017-08-23
- 1.0.2 — 2017-02-23
- 1.0.1 — 2017-02-23
- 1.0.0 — 2014-10-13

## README

# browser-locale

[![NPM](https://nodei.co/npm/browser-locale.png?global=true)](https://nodei.co/npm/browser-locale/)

normalizes weird cross browser issues and tries to return the users selected language in 100% client side JS by looking at various properties on the `window.navigator` object

note that another technique used to detect the browsers user-set language preference is to look at the `accept-language` header set on outgoing http requests, but this requires making a round trip XHR to a server, which is what [jquery-browser-language](https://github.com/dansingerman/jQuery-Browser-Language) does.

however, it seems that as of 2014 you can get the user specified language without making a HTTP request (see `index.js` for details)

## installation

```
npm install browser-locale
```

use [browserify](http://browserify.org) or [browserify-cdn](http://wzrd.in) to package it for browser use

## usage

```js
var locale = require('browser-locale')()
// locale will be e.g. en-US or undefined if it could not be detected (e.g. you are in a super weird browser)
```

## tips

Not all browsers are consistent in their capitalization of language tags,
e.g. `en-US` vs `en-us`. Keep this in mind when looking for matches in locale
strings.

See also [locale2](https://github.com/moimikey/locale2), an alternative module
for detecting a user's locale.

---
_Source: https://npm.io/package/browser-locale · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
