diff --git a/components/Home.js b/components/Home.js
index 28d98e8..3a65aed 100644
--- a/components/Home.js
+++ b/components/Home.js
@@ -16,11 +16,11 @@ import { determinePredictionText, formatWithOrdinalSuffix } from './helpers/home
import { Colors, Fonts, Sizes, Spacing } from '../styles'
import { LocalDate } from 'js-joda'
-import useComponentTranslation from '../hooks/useComponentTranslation'
+import { useTranslation } from 'react-i18next'
const Home = ({ navigate, setDate }) => {
- const { t } = useComponentTranslation('components.Home')
+ const { t } = useTranslation()
function navigateToCycleDayView() {
setDate(todayDateString)
@@ -46,7 +46,7 @@ const Home = ({ navigate, setDate }) => {
{cycleDayNumber &&
{cycleDayText}
- {t('cycleDay')}
+ {t('labels.home.cycleDay')}
}
{phase &&
@@ -55,7 +55,7 @@ const Home = ({ navigate, setDate }) => {
{formatWithOrdinalSuffix(phase)}
- {t('cyclePhase')}
+ {t('labels.home.cyclePhase')}
{status}
@@ -65,7 +65,7 @@ const Home = ({ navigate, setDate }) => {
{prediction}
{phase && (
diff --git a/components/helpers/home.js b/components/helpers/home.js
index 8ddb00c..3034023 100644
--- a/components/helpers/home.js
+++ b/components/helpers/home.js
@@ -18,7 +18,7 @@ function getTimes(prediction) {
}
export function determinePredictionText(bleedingPrediction, t) {
- if (!bleedingPrediction.length) return t('noPrediction')
+ if (!bleedingPrediction.length) return t('labels.bleedingPrediction.noPrediction')
const {
todayDate,
predictedBleedingStart,
diff --git a/hooks/useComponentTranslation.js b/hooks/useComponentTranslation.js
deleted file mode 100644
index 968491d..0000000
--- a/hooks/useComponentTranslation.js
+++ /dev/null
@@ -1,11 +0,0 @@
-import { useTranslation } from "react-i18next"
-
-export default function useComponentTranslation(componentPath) {
- const { t, i18n } = useTranslation();
- function translate(code, options) {
- const mergedPath = `${componentPath}.${code}`;
- const translation = t(mergedPath, options);
- return translation !== mergedPath ? translation : t(code, options);
- }
- return { t: translate, i18n };
-}
\ No newline at end of file
diff --git a/i18n/en.json b/i18n/en.json
index d74e3ec..079edfc 100644
--- a/i18n/en.json
+++ b/i18n/en.json
@@ -1,10 +1,12 @@
{
- "components": {
- "Home": {
- "addDataForToday": "add data for today",
- "noPrediction": "As soon as you have tracked 3 menstrual cycles, drip will make predictions for the next ones.",
+ "labels": {
+ "home": {
"cycleDay": " day of your cycle",
- "cyclePhase": " cycle phase - "
+ "cyclePhase": " cycle phase - ",
+ "addDataForToday": "add data for today"
+ },
+ "bleedingPrediction": {
+ "noPrediction": "As soon as you have tracked 3 menstrual cycles, drip will make predictions for the next ones."
}
- }
-}
+ }
+}
\ No newline at end of file