-
Notifications
You must be signed in to change notification settings - Fork 3
/
App.tsx
109 lines (98 loc) · 3.09 KB
/
App.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import React, {useState} from 'react';
import {
SafeAreaView,
StyleSheet,
Text,
StatusBar,
ScrollView,
Button,
} from 'react-native';
import './localization';
import {useTranslation} from 'react-i18next';
import LanguageSelector from './LanguageSelector';
import Section from './Section';
import moment from 'moment';
declare const global: {HermesInternal: null | {}};
const App = () => {
const {t} = useTranslation();
// -- Funny Message loading logic --
const [funnyMessageIndex, setFunnyMessageIndex] = useState(0);
const jumbleJumble = () => {
if (funnyMessages.length < 2) {
return funnyMessages[0];
}
let newIndex = funnyMessageIndex;
while (newIndex === funnyMessageIndex) {
newIndex = Math.floor(Math.random() * funnyMessages.length);
}
setFunnyMessageIndex(newIndex);
};
// -- Funny Message loading logic ends --
const user = {
username: 'Nishant',
intelligenceLevel: 7,
};
const userBill = {
total: 420.69,
paymentDueDate: 'May the fourth',
};
const genderPronouns = ['she', 'he', 'they', 'ze', 'ey'];
const funnyMessages = t('funnyLoadingMessages', {returnObjects: true});
return (
<>
<StatusBar barStyle="dark-content" backgroundColor="white" />
<SafeAreaView style={styles.main}>
<ScrollView style={styles.scroll}>
<Section title="NAMESPACES">
<Text>homePage NS: {t('homePage:welcome')}</Text>
<Text>Deafult NS: {t('ok')}</Text>
</Section>
<Section title="CHANGE LANGUAGE">
<LanguageSelector />
</Section>
<Section title="INTERPOLATION">
<Text>{t('accountSuspended', {user, userBill})}</Text>
</Section>
<Section title="CUSTOM FORMAT">
<Text>{t('flagsCount', {count: 3})}</Text>
<Text>
Moment.js Locale 42 minutes ago:
{moment().subtract(42, 'minutes').fromNow()}
</Text>
</Section>
<Section title="PLURALIZATION">
<Text>{t('autopsy', {count: 0})}</Text>
<Text>{t('autopsy', {count: 1})}</Text>
<Text>{t('autopsy', {count: 7})}</Text>
</Section>
<Section title="CONTEXT: GENDER">
{genderPronouns.map((context) => (
<Text key={context}>{t('loveThyself', {context})}</Text>
))}
</Section>
<Section title="CONTEXT: PLURALIZATION">
<Text>{t('autopsy', {count: 0, context: '0'})}</Text>
<Text>{t('autopsy', {count: 1, context: '1'})}</Text>
<Text>{t('autopsy', {count: 7, context: '7'})}</Text>
</Section>
<Section title="ARRAYS AND OBJECTS">
<Text>{funnyMessages[funnyMessageIndex]}</Text>
<Button onPress={() => jumbleJumble()} title="ANOTHER MESSAGE" />
</Section>
</ScrollView>
</SafeAreaView>
</>
);
};
const styles = StyleSheet.create({
main: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
// width: '100%',
},
scroll: {
flex: 1,
},
});
export default App;