From a08c53ba1e109f3bfe03ee64f249cdea2fc8a79c Mon Sep 17 00:00:00 2001 From: Sendou <38327916+Sendouc@users.noreply.github.com> Date: Sun, 21 Jun 2020 15:21:25 +0300 Subject: [PATCH] home page trans --- .../public/locales/en/translation.json | 15 ++ .../src/components/home/HomePage.tsx | 4 +- frontend-react/src/components/home/Stats.tsx | 130 +++++++++++------- .../src/components/home/WeeksTournaments.tsx | 6 +- .../src/components/root/SideNavContent.tsx | 6 +- 5 files changed, 103 insertions(+), 58 deletions(-) diff --git a/frontend-react/public/locales/en/translation.json b/frontend-react/public/locales/en/translation.json index 59bb3c8c2..25e2c86f1 100644 --- a/frontend-react/public/locales/en/translation.json +++ b/frontend-react/public/locales/en/translation.json @@ -940,5 +940,20 @@ "Profile": "Profile", "Log out": "Log out", "Log in via Discord": "Log in via Discord" + }, + "home": { + "Competitive Splatoon Hub": "Competitive Splatoon Hub", + "Play in competitive events this week": "Play in competitive events this week", + "View more info": "View more info", + "Featuring...": "Featuring...", + "xRankMonths": "{{xRankMonthCount}} months of <3><0>X Rank Top 500 data", + "buildCount": "<0> <2><0>builds", + "userCount": "<0> <2><0>users", + "faCount": "<0> <2><0>free agents", + "tournamentCount": "<0> <2><0>tournament results", + "As well as": "As well as", + "calendarExplanation": "<0><0>Calendar to discover upcoming events", + "drawingToolExplanation": "<0><0>Map drawing tool to easily share your plans", + "analyzerExplanation": "<0><0>Build analyzer to find out exactly what your builds are doing" } } diff --git a/frontend-react/src/components/home/HomePage.tsx b/frontend-react/src/components/home/HomePage.tsx index 1dce1a715..7bad04f74 100644 --- a/frontend-react/src/components/home/HomePage.tsx +++ b/frontend-react/src/components/home/HomePage.tsx @@ -8,9 +8,11 @@ import "./HomePage.css" import { Helmet } from "react-helmet-async" import Stats from "./Stats" import WeeksTournaments from "./WeeksTournaments" +import { useTranslation } from "react-i18next" const HomePage: React.FC = () => { const { colorMode, grayWithShade } = useContext(MyThemeContext) + const { t } = useTranslation() return ( <> @@ -32,7 +34,7 @@ const HomePage: React.FC = () => { fontWeight="light" color={grayWithShade} > - Competitive Splatoon Hub + {t("home;Competitive Splatoon Hub")} diff --git a/frontend-react/src/components/home/Stats.tsx b/frontend-react/src/components/home/Stats.tsx index 980171337..d10d05eb9 100644 --- a/frontend-react/src/components/home/Stats.tsx +++ b/frontend-react/src/components/home/Stats.tsx @@ -5,6 +5,7 @@ import React, { useContext } from "react" import { STATS } from "../../graphql/queries/stats" import MyThemeContext from "../../themeContext" import Error from "../common/Error" +import { useTranslation, Trans } from "react-i18next" interface StatsData { stats: { @@ -24,12 +25,17 @@ const xRankMonths = () => { const Stats: React.FC = () => { const { grayWithShade, themeColorWithShade } = useContext(MyThemeContext) const { data, error } = useQuery(STATS) + const { t } = useTranslation() if (error) return const stats = data?.stats - const getStatString = (value?: number) => { + interface StatOrSkeletonProps { + value?: number + } + + const StatOrSkeleton: React.FC = ({ value }) => { if (!value) { return ( { /> ) } - return value + return <>{value} } + const getStatString = (_asd: any) => 2 + + const xRankMonthCount = xRankMonths() + return ( <> - Featuring... + {t("home;Featuring...")} { textAlign="center" > - {xRankMonths()} months of{" "} - - - X Rank Top 500 data - - + + {{ xRankMonthCount }} months of{" "} + + + X Rank Top 500 data + + + - {getStatString(stats?.build_count)}{" "} - - - builds - - + + {" "} + + + builds + + + - {getStatString(stats?.user_count)}{" "} - - - users - - {" "} + + {" "} + + + users + + {" "} + - {getStatString(stats?.fa_count)}{" "} - - - free agents - - + + {" "} + + + free agents + + + - {getStatString(stats?.tournament_count)}{" "} - - - tournament results - - + + {" "} + + + tournament results + + + - As well as + {t("home;As well as")} { textAlign="center" > - - - Calendar - - {" "} - to discover upcoming events + + + + Calendar + + {" "} + to discover upcoming events + - - - Map drawing tool - - {" "} - to easily share your plans + + + + Map drawing tool + + {" "} + to easily share your plans + - - - Build analyzer - - {" "} - to find out exactly what your builds are doing + + + + Build analyzer + + {" "} + to find out exactly what your builds are doing + diff --git a/frontend-react/src/components/home/WeeksTournaments.tsx b/frontend-react/src/components/home/WeeksTournaments.tsx index 791c2803a..b5c901d32 100644 --- a/frontend-react/src/components/home/WeeksTournaments.tsx +++ b/frontend-react/src/components/home/WeeksTournaments.tsx @@ -13,10 +13,12 @@ import { FiClock, FiInfo } from "react-icons/fi" import MyThemeContext from "../../themeContext" import Button from "../elements/Button" import { Link } from "@reach/router" +import { useTranslation } from "react-i18next" const WeeksTournaments: React.FC = () => { const { themeColorWithShade, grayWithShade } = useContext(MyThemeContext) const { data, error, loading } = useQuery(UPCOMING_EVENTS) + const { t } = useTranslation() if (loading) return if (error) return @@ -31,7 +33,7 @@ const WeeksTournaments: React.FC = () => { return ( <> - Play in competitive events this week + {t("home;Play in competitive events this week")} {events.map((tournament) => ( { diff --git a/frontend-react/src/components/root/SideNavContent.tsx b/frontend-react/src/components/root/SideNavContent.tsx index 64136df60..62c317fd9 100644 --- a/frontend-react/src/components/root/SideNavContent.tsx +++ b/frontend-react/src/components/root/SideNavContent.tsx @@ -76,7 +76,7 @@ const UserItem: React.FC<{ data?: UserData }> = ({ data }) => { color={themeColorWithShade} size="1.5em" />{" "} - {t("Log in via Discord")} + {t("navigation;Log in via Discord")} @@ -101,7 +101,7 @@ const UserItem: React.FC<{ data?: UserData }> = ({ data }) => { {" "} - {t("Profile")} + {t("navigation;Profile")} @@ -111,7 +111,7 @@ const UserItem: React.FC<{ data?: UserData }> = ({ data }) => { {" "} - {t("Log out")} + {t("navigation;Log out")}