# react-native-default-locale

> Get active locale from device on iOS, Android and Web platforms

Latest version **0.1.2** (published 2019-10-10) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install react-native-default-locale
pnpm add react-native-default-locale
yarn add react-native-default-locale
bun add react-native-default-locale
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2019-10-10 |
| First published | 2019-10-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | oxyii |

## Links

- npm: https://www.npmjs.com/package/react-native-default-locale
- Repository: https://github.com/oxyii/react-native-default-locale
- Homepage: https://github.com/oxyii/react-native-default-locale#readme
- Issues: https://github.com/oxyii/react-native-default-locale/issues
- npm.io page: https://npm.io/package/react-native-default-locale

## Recent versions

- 0.1.2 (latest) — 2019-10-10
- 0.1.0 — 2019-10-10

## README

# react-native-default-locale

Very simple react-native device locale detector on iOS, Android and Web platforms.

I'm confused about several standards of locale formats. `en_US` and `en-US` is equal for humans but not for string validator.
So this lib just get active locale from device and split it into `language` and `country`. Both can be `null`.

- Android: get `RN.NativeModules.I18nManager.localeIdentifier`
- iOS: get `RN.NativeModules.SettingsManager.settings.AppleLocale`
- iOS 13: get `RN.NativeModules.SettingsManager.settings.AppleLanguages[0]` (see [here](https://github.com/facebook/react-native/issues/26540#issuecomment-535720033))
- Web: get `window.navigator.languages[0] || window.navigator.language`

## Expo projects

[`expo-localization`](https://docs.expo.io/versions/latest/sdk/localization/) works perfect. So you don't need to install `react-native-default-locale`.

## Installation

```bash
$ npm i react-native-default-locale --save
```

## Usage

```js
import locale from 'react-native-default-locale';
...
const language = locale.language; // en
const country = locale.country; // US
```
or simple
```js
import { language, country } from 'react-native-default-locale';
```

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