Last active
July 20, 2021 20:36
-
-
Save sayurimizuguchi/d2975e9f85f14286ab5cba05ed251b63 to your computer and use it in GitHub Desktop.
Get current language locale setting in the phone iOS and Android - React Native
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NativeModules, Platform } from 'react-native'; | |
/** | |
* use NativeModules to get devide languages | |
* both iOS and Android, default format is language_Country e.g en_US | |
* @return {string} language | |
*/ | |
const deviceLanguage = Platform.OS === 'ios' | |
? NativeModules.SettingsManager.settings.AppleLocale | |
: NativeModules.I18nManager.localeIdentifier; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment