diff --git a/src/i18n/common.json b/src/i18n/common.json index 4d7505a4dc..6ec2b2e908 100644 --- a/src/i18n/common.json +++ b/src/i18n/common.json @@ -1,4 +1,20 @@ { + "home": { + "statistics": { + "editorCount": { + "title": "Editor", + "description": "Number of edition done" + }, + "contributorCount": { + "title": "Contributor", + "description": "Adding a new product" + }, + "photographerCount": { + "title": "Photographer", + "description": "Taking photos for a product" + } + } + }, "questions": { "category": "category", "label": "label", @@ -210,4 +226,4 @@ "redirect1": "Want to play some games?", "redirect2": "Click here" } -} +} \ No newline at end of file diff --git a/src/i18n/en.json b/src/i18n/en.json index d153652738..a42742e4cd 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -1,4 +1,20 @@ { + "home": { + "statistics": { + "editorCount": { + "title": "Editor", + "description": "Number of edition done" + }, + "contributorCount": { + "title": "Contributor", + "description": "Adding a new product" + }, + "photographerCount": { + "title": "Photographer", + "description": "Taking photos for a product" + } + } + }, "questions": { "category": "category", "label": "label", @@ -210,4 +226,4 @@ "redirect1": "Want to play some games?", "redirect2": "Click here" } -} +} \ No newline at end of file diff --git a/src/pages/home/UserData.jsx b/src/pages/home/UserData.jsx index e19000de13..491421b283 100644 --- a/src/pages/home/UserData.jsx +++ b/src/pages/home/UserData.jsx @@ -6,10 +6,9 @@ import Card from "@mui/material/Card"; import CardContent from "@mui/material/CardContent"; import Typography from "@mui/material/Typography"; import Stack from "@mui/material/Stack"; +import { useTranslation } from "react-i18next"; const fetchUserData = async (userName) => { - console.log(userName); - const editorPromise = axios .get(`https://world.openfoodfacts.org/editor/${userName}.json?fields=count`) .then(({ data }) => { @@ -42,18 +41,30 @@ const fetchUserData = async (userName) => { photographerPromise, ]); - console.log(editorCount, contributorCount, photographerCount); return { editorCount, contributorCount, photographerCount }; }; const CountCard = (props) => { const { translationKey, value } = props; + const { t } = useTranslation(); + return ( - - {translationKey} + + {t(`home.statistics.${translationKey}.title`)} + + + {t(`home.statistics.${translationKey}.description`)} {value.toLocaleString()} @@ -74,7 +85,7 @@ const UserData = ({ userName }) => { }) .catch(() => {}); }, [userName]); - console.log(counts); + return (