New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-native-default-locale

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-default-locale

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

latest
Source
npmnpm
Version
0.1.2
Version published
Maintainers
1
Created
Source

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)
  • Web: get window.navigator.languages[0] || window.navigator.language

Expo projects

expo-localization works perfect. So you don't need to install react-native-default-locale.

Installation

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

Usage

import locale from 'react-native-default-locale';
...
const language = locale.language; // en
const country = locale.country; // US

or simple

import { language, country } from 'react-native-default-locale';

FAQs

Package last updated on 10 Oct 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts