File tree Expand file tree Collapse file tree 1 file changed +11
-8
lines changed
packages/sdk/react-native/src/platform Expand file tree Collapse file tree 1 file changed +11
-8
lines changed Original file line number Diff line number Diff line change 11import { NativeModules , Platform } from 'react-native' ;
2-
32/**
4- * Ripped from:
5- * https://dev.to/medaimane/localization-and-internationalization-in-react-native-reaching-global-audiences-3acj
3+ * Apps opted into Fabric (the new architecture of React Native)
4+ * may not have access to the SettingsManager.settings.AppleLocale property.
5+ * It is now common to use the `getConstants` method to access these constant properties with Fabric enabled apps.
66 */
7- const locale =
8- Platform . OS === 'ios'
9- ? NativeModules . SettingsManager ?. settings ?. AppleLocale // iOS
10- : NativeModules . I18nManager ?. localeIdentifier ;
7+ const getAppleLocale = ( ) => {
8+ const settings = NativeModules . SettingsManager ?. settings ?? NativeModules . SettingsManager ?. getConstants ( ) ?. settings ;
9+ return settings ?. AppleLocale ;
10+ }
1111
12- export default locale ;
12+ export default Platform . select ( {
13+ ios : getAppleLocale ( ) ,
14+ android : NativeModules . I18nManager ?. localeIdentifier ,
15+ } )
You can’t perform that action at this time.
0 commit comments