615 Use translation library for bottom menu

This commit is contained in:
Lisa Hillebrand
2022-09-30 11:39:00 +02:00
parent 9dfe8b4b05
commit 36c33c69b7
3 changed files with 14 additions and 6 deletions
+6 -3
View File
@@ -6,20 +6,23 @@ import MenuItem from './menu-item'
import { Containers } from '../../styles' import { Containers } from '../../styles'
import { pages } from '../pages' import { pages } from '../pages'
import { useTranslation } from 'react-i18next'
const Menu = ({ currentPage, navigate }) => { const Menu = ({ currentPage, navigate }) => {
const menuItems = pages.filter((page) => page.isInMenu) const menuItems = pages.filter((page) => page.isInMenu)
const { t } = useTranslation(null, { keyPrefix: 'bottomMenu' })
return ( return (
<View style={styles.container}> <View style={styles.container}>
{menuItems.map(({ icon, label, component }) => { {menuItems.map(({ icon, labelKey, component }) => {
return ( return (
<MenuItem <MenuItem
isActive={component === currentPage} isActive={component === currentPage}
onPress={() => navigate(component)} onPress={() => navigate(component)}
icon={icon} icon={icon}
key={label} key={labelKey}
label={label} label={t(labelKey)}
/> />
) )
})} })}
+3 -3
View File
@@ -13,21 +13,21 @@ export const pages = [
component: 'Calendar', component: 'Calendar',
icon: 'calendar', icon: 'calendar',
isInMenu: true, isInMenu: true,
label: 'Calendar', labelKey: 'calendar',
parent: 'Home', parent: 'Home',
}, },
{ {
component: 'Chart', component: 'Chart',
icon: 'chart', icon: 'chart',
isInMenu: true, isInMenu: true,
label: 'Chart', labelKey: 'chart',
parent: 'Home', parent: 'Home',
}, },
{ {
component: 'Stats', component: 'Stats',
icon: 'statistics', icon: 'statistics',
isInMenu: true, isInMenu: true,
label: 'Stats', labelKey: 'stats',
parent: 'Home', parent: 'Home',
}, },
{ {
+5
View File
@@ -1,4 +1,9 @@
{ {
"bottomMenu": {
"calendar": "Calendar",
"chart": "Chart",
"stats": "Stats"
},
"cycleDay": { "cycleDay": {
"symptomBox": { "symptomBox": {
"bleeding": "Bleeding", "bleeding": "Bleeding",