@@ -6,12 +6,12 @@ import * as RNLocalize from 'react-native-localize';
6
6
import i18n from 'i18n-js' ;
7
7
import memoize from 'lodash.memoize' ;
8
8
9
- import { I18nManager , SafeAreaView , ScrollView , StyleSheet , Text , View } from 'react-native' ;
9
+ import { I18nManager , SafeAreaView , StyleSheet , Text } from 'react-native' ;
10
10
11
11
const translationGetters = {
12
12
// lazy requires (metro bundler does not support symlinks)
13
- ar : ( ) => require ( './src/translations/ar.json' ) ,
14
13
en : ( ) => require ( './src/translations/en.json' ) ,
14
+ ar : ( ) => require ( './src/translations/ar.json' ) ,
15
15
fr : ( ) => require ( './src/translations/fr.json' ) ,
16
16
} ;
17
17
@@ -30,13 +30,12 @@ const setI18nConfig = () => {
30
30
translate . cache . clear ( ) ;
31
31
// update layout direction
32
32
I18nManager . forceRTL ( isRTL ) ;
33
-
34
33
// set i18n-js config
35
34
i18n . translations = { [ languageTag ] : translationGetters [ languageTag ] ( ) } ;
36
35
i18n . locale = languageTag ;
37
36
} ;
38
37
39
- export default class SyncExample extends React . Component {
38
+ export default class App extends React . Component {
40
39
constructor ( props ) {
41
40
super ( props ) ;
42
41
setI18nConfig ( ) ; // set initial config
@@ -58,54 +57,20 @@ export default class SyncExample extends React.Component {
58
57
render ( ) {
59
58
return (
60
59
< SafeAreaView style = { styles . safeArea } >
61
- < ScrollView contentContainerStyle = { styles . container } >
62
- < Line name = "RNLocalize.getLocales()" value = { RNLocalize . getLocales ( ) } />
63
- < Line name = "RNLocalize.getCurrencies()" value = { RNLocalize . getCurrencies ( ) } />
64
- < Line name = "RNLocalize.getCountry()" value = { RNLocalize . getCountry ( ) } />
65
- < Line name = "RNLocalize.getCalendar()" value = { RNLocalize . getCalendar ( ) } />
66
- < Line name = "RNLocalize.getNumberFormatSettings()" value = { RNLocalize . getNumberFormatSettings ( ) } />
67
- < Line name = "RNLocalize.getTemperatureUnit()" value = { RNLocalize . getTemperatureUnit ( ) } />
68
- < Line name = "RNLocalize.getTimeZone()" value = { RNLocalize . getTimeZone ( ) } />
69
- < Line name = "RNLocalize.uses24HourClock()" value = { RNLocalize . uses24HourClock ( ) } />
70
- < Line name = "RNLocalize.usesMetricSystem()" value = { RNLocalize . usesMetricSystem ( ) } />
71
- < Line
72
- name = "RNLocalize.findBestAvailableLanguage(['en-US', 'en', 'fr'])"
73
- value = { RNLocalize . findBestAvailableLanguage ( [ 'en-US' , 'en' , 'fr' ] ) }
74
- />
75
-
76
- < Line name = "Translation example" value = { translate ( 'hello' ) } />
77
- </ ScrollView >
60
+ < Text style = { styles . value } > { translate ( 'hello' ) } </ Text >
78
61
</ SafeAreaView >
79
62
) ;
80
63
}
81
64
}
82
65
83
- const Line = props => (
84
- < View style = { styles . block } >
85
- < Text style = { styles . name } > { props . name } </ Text >
86
- < Text style = { styles . value } > { JSON . stringify ( props . value , null , 2 ) } </ Text >
87
- </ View >
88
- ) ;
89
-
90
66
const styles = StyleSheet . create ( {
91
67
safeArea : {
92
68
backgroundColor : 'white' ,
93
69
flex : 1 ,
94
- } ,
95
- container : {
96
- padding : 16 ,
97
- alignItems : 'flex-start' ,
98
- } ,
99
- block : {
100
- marginBottom : 16 ,
101
- alignItems : 'flex-start' ,
102
- } ,
103
- name : {
104
- textDecorationLine : 'underline' ,
105
- fontWeight : '500' ,
106
- marginBottom : 8 ,
70
+ alignItems : 'center' ,
71
+ justifyContent : 'center' ,
107
72
} ,
108
73
value : {
109
- textAlign : 'left' ,
74
+ fontSize : 18 ,
110
75
} ,
111
76
} ) ;
0 commit comments