@flyskywhy/react-native-locale-detector

Detects the locale of a user's phone. Based on react-native-i18n, but this just exports the device's locale. This isn't particularly useful on it's own and you'll probably want to use it with an i18n library like i18next.

Usage no npm install needed!

<script type="module">
  import flyskywhyReactNativeLocaleDetector from 'https://cdn.skypack.dev/@flyskywhy/react-native-locale-detector';
</script>

README

react-native-locale-detector

Detects the locale of a user's phone. Based on react-native-i18n, but this just exports the device's locale. This isn't particularly useful on it's own and you'll probably want to use it with an i18n library like i18next.

Installation

npm install @flyskywhy/react-native-locale-detector --save

For RN < 0.60

react-native link

Usage

// Import the locale.
import locale from '@flyskywhy/react-native-locale-detector'

// We could log it. Maybe it's en-US...
console.log(locale)

// Or if you're using a localization library.
yourLocalizationLibrary.setLocale(locale)