Skip to content

Commit f13448b

Browse files
committed
update main code
1 parent 93c9f83 commit f13448b

File tree

2 files changed

+9
-44
lines changed

2 files changed

+9
-44
lines changed

App.js

+7-42
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ import * as RNLocalize from 'react-native-localize';
66
import i18n from 'i18n-js';
77
import memoize from 'lodash.memoize';
88

9-
import { I18nManager, SafeAreaView, ScrollView, StyleSheet, Text, View } from 'react-native';
9+
import { I18nManager, SafeAreaView, StyleSheet, Text } from 'react-native';
1010

1111
const translationGetters = {
1212
// lazy requires (metro bundler does not support symlinks)
13-
ar: () => require('./src/translations/ar.json'),
1413
en: () => require('./src/translations/en.json'),
14+
ar: () => require('./src/translations/ar.json'),
1515
fr: () => require('./src/translations/fr.json'),
1616
};
1717

@@ -30,13 +30,12 @@ const setI18nConfig = () => {
3030
translate.cache.clear();
3131
// update layout direction
3232
I18nManager.forceRTL(isRTL);
33-
3433
// set i18n-js config
3534
i18n.translations = { [languageTag]: translationGetters[languageTag]() };
3635
i18n.locale = languageTag;
3736
};
3837

39-
export default class SyncExample extends React.Component {
38+
export default class App extends React.Component {
4039
constructor(props) {
4140
super(props);
4241
setI18nConfig(); // set initial config
@@ -58,54 +57,20 @@ export default class SyncExample extends React.Component {
5857
render() {
5958
return (
6059
<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>
7861
</SafeAreaView>
7962
);
8063
}
8164
}
8265

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-
9066
const styles = StyleSheet.create({
9167
safeArea: {
9268
backgroundColor: 'white',
9369
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',
10772
},
10873
value: {
109-
textAlign: 'left',
74+
fontSize: 18,
11075
},
11176
});

index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
* @format
33
*/
44

5-
import {AppRegistry} from 'react-native';
5+
import { AppRegistry } from 'react-native';
66
import App from './App';
7-
import {name as appName} from './app.json';
7+
import { name as appName } from './app.json';
88

99
AppRegistry.registerComponent(appName, () => App);

0 commit comments

Comments
 (0)