An open API service indexing awesome lists of open source software.

https://github.com/seregpie/detectnearestbrowserlocale

Detects the nearest browser locale.
https://github.com/seregpie/detectnearestbrowserlocale

browser detect language locale navigator

Last synced: 5 months ago
JSON representation

Detects the nearest browser locale.

Awesome Lists containing this project

README

        

# detectNearestBrowserLocale

`detectNearestBrowserLocale(supportedLocales)`

Detects the nearest browser locale.

| argument | description |
| ---: | :--- |
| `supportedLocales` | An array of the supported locales. |

Returns the first matching supported locale.

## dependencies

- [detectNearestLocale](https://github.com/SeregPie/detectNearestLocale)

## setup

### npm

```shell
npm i detect-nearest-browser-locale
```

### ES module

```javascript
import detectNearestBrowserLocale from 'detect-nearest-browser-locale';
```

### browser

```html

```

## usage

```javascript
// navigator.languages => ['de', 'en-GB']
let locale = detectNearestBrowserLocale(['ru', 'en-US']);
// => 'en-US'
```