I would like my app to support multiple languages, for example English and Chinese. Using react native, how do I find the language settings on the phone?
I would like my app to support multiple languages, for example English and Chinese. Using react native, how do I find the language settings on the phone?
import { NativeModules, Platform } from 'react-native';
const deviceLanguage =
Platform.OS === 'ios'
? NativeModules.SettingsManager.settings.AppleLocale ||
NativeModules.SettingsManager.settings.AppleLanguages[0] // iOS 13
: NativeModules.I18nManager.localeIdentifier;
console.log(deviceLanguage); //en_US
Try using this library -> https://github.com/AlexanderZaytsev/react-native-i18n
import I18n from 'react-native-i18n';
deviceLocale = I18n.currentLocale()
import { NativeModules, Platform } from 'react-native';
let deviceLanguage = Platform.OS === 'ios' ?
NativeModules.SettingsManager.settings.AppleLocale:
NativeModules.I18nManager.localeIdentifier;
if (deviceLanguage === undefined) {
// iOS 13 workaround, take first of AppleLanguages array
deviceLanguage = NativeModules.SettingsManager.settings.AppleLanguages[0]
if (deviceLanguage == undefined) {
return defaultLocalization // default language
}
}