Add multilanguage support
This commit is contained in:
parent
f8cbcb2908
commit
fc53bb14a0
15 changed files with 489 additions and 92 deletions
|
@ -5,6 +5,7 @@ import CalendarPicker from 'react-native-calendar-picker';
|
|||
import { useIsFocused } from '@react-navigation/core';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { LogLevel, OneSignal } from 'react-native-onesignal';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
import { ThemedText } from '@/lib/components/ThemedText';
|
||||
import { ThemedView } from '@/lib/components/ThemedView';
|
||||
|
@ -19,9 +20,10 @@ import { ThemedIcon } from '@/lib/components/ThemedIcon';
|
|||
export default function HomeScreen() {
|
||||
const colorScheme = useColorScheme() ?? 'light';
|
||||
const isFocused = useIsFocused();
|
||||
const { t } = useTranslation();
|
||||
const session = useSelector( (state: any) => state.data.session );
|
||||
const reloadCalendar = useSelector( (state: any) => state.data.reloadCalendar );
|
||||
const { token, isLoading } = useToken();
|
||||
const { token } = useToken();
|
||||
const [ name, setName ] = useState( ' ' ); // Default empty space to prevent layout shifting
|
||||
const [ dates, setDates ] = useState<any | null>( [] );
|
||||
const [ types, setTypes ] = useState<any | null>( [] );
|
||||
|
@ -68,6 +70,21 @@ export default function HomeScreen() {
|
|||
}
|
||||
}, [ reloadCalendar, isFocused ] );
|
||||
|
||||
const getGreeting = () => {
|
||||
const myDate = new Date();
|
||||
const hours = myDate.getHours();
|
||||
|
||||
if (hours < 12) {
|
||||
return t( "greeting.morning" );
|
||||
} else if (hours >= 12 && hours <= 17) {
|
||||
return t( "greeting.afternoon" );
|
||||
} else if (hours >= 17 && hours <= 24) {
|
||||
return t( "greeting.evening" );
|
||||
}
|
||||
|
||||
return t( "greeting.hello" );
|
||||
}
|
||||
|
||||
// Load calendar data
|
||||
const loadCalendar = () => {
|
||||
Request.post( 'calendar', { token: token } ).then( (response) => {
|
||||
|
@ -116,26 +133,34 @@ export default function HomeScreen() {
|
|||
nextComponent={
|
||||
<ThemedIcon size={28} name="chevron-forward"/>
|
||||
}
|
||||
weekdays={[ "Ma", "Di", "Woe", "Do", "Vrij", "Zat", "Zo" ]}
|
||||
weekdays={[
|
||||
t( "days.mon" ),
|
||||
t( "days.tue" ),
|
||||
t( "days.wed" ),
|
||||
t( "days.thu" ),
|
||||
t( "days.fri" ),
|
||||
t( "days.sat" ),
|
||||
t( "days.sun" ),
|
||||
]}
|
||||
months={[
|
||||
"Januari",
|
||||
"Februari",
|
||||
"Maart",
|
||||
"April",
|
||||
"Mei",
|
||||
"Juni",
|
||||
"Juli",
|
||||
"Augustus",
|
||||
"September",
|
||||
"Oktober",
|
||||
"November",
|
||||
"December",
|
||||
t( "months.january" ),
|
||||
t( "months.february" ),
|
||||
t( "months.march" ),
|
||||
t( "months.april" ),
|
||||
t( "months.may" ),
|
||||
t( "months.june" ),
|
||||
t( "months.july" ),
|
||||
t( "months.august" ),
|
||||
t( "months.september" ),
|
||||
t( "months.october" ),
|
||||
t( "months.november" ),
|
||||
t( "months.december" ),
|
||||
]}
|
||||
/>
|
||||
</ThemedView>
|
||||
|
||||
<ThemedView style={styles.legendaContainer}>
|
||||
<ThemedText type='subtitle'>Legenda:</ThemedText>
|
||||
<ThemedText type='subtitle'>{t( "legenda" )}:</ThemedText>
|
||||
<List
|
||||
data={types}
|
||||
viewStyle={styles.legendaList}
|
||||
|
@ -153,21 +178,6 @@ export default function HomeScreen() {
|
|||
);
|
||||
}
|
||||
|
||||
function getGreeting() {
|
||||
const myDate = new Date();
|
||||
const hours = myDate.getHours();
|
||||
|
||||
if (hours < 12) {
|
||||
return 'Goedemorgen';
|
||||
} else if (hours >= 12 && hours <= 17) {
|
||||
return 'Goedemiddag';
|
||||
} else if (hours >= 17 && hours <= 24) {
|
||||
return 'Goedenavond';
|
||||
}
|
||||
|
||||
return 'Hallo';
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create( {
|
||||
container: {
|
||||
padding: 25,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue