From f9140b12c3ae6bb3bcb1de6b8bea31cbaff5f683 Mon Sep 17 00:00:00 2001 From: Sendou <38327916+Sendouc@users.noreply.github.com> Date: Sat, 27 Jun 2020 13:49:17 +0300 Subject: [PATCH] x trends translated --- .../public/locales/en/translation.json | 3 ++ .../src/components/xsearch/Top500Forms.tsx | 18 +-------- .../components/xtrends/WeaponLineChart.tsx | 14 ++++--- .../src/components/xtrends/XTrendsPage.tsx | 38 ++++++++++++++----- frontend-react/src/utils/helperFunctions.ts | 30 +++++++++++++++ 5 files changed, 71 insertions(+), 32 deletions(-) diff --git a/frontend-react/public/locales/en/translation.json b/frontend-react/public/locales/en/translation.json index c16a138cf..9caf9405d 100644 --- a/frontend-react/public/locales/en/translation.json +++ b/frontend-react/public/locales/en/translation.json @@ -1504,5 +1504,8 @@ "X Power": "X Power", "Placement": "Placement", "ID": "ID" + }, + "xtrends": { + "trendsExplanation": "Here you can find X Rank Top 500 usage tier lists. For example for a weapon to be in the X tier it needs at least 30 placements in that mode that month." } } diff --git a/frontend-react/src/components/xsearch/Top500Forms.tsx b/frontend-react/src/components/xsearch/Top500Forms.tsx index 4d8bf5221..a73140944 100644 --- a/frontend-react/src/components/xsearch/Top500Forms.tsx +++ b/frontend-react/src/components/xsearch/Top500Forms.tsx @@ -8,6 +8,7 @@ import Select from "../elements/Select" import Label from "../elements/Label" import { Weapon } from "../../types" import { useTranslation } from "react-i18next" +import { getLocalizedMonthYearString } from "../../utils/helperFunctions" interface Top500FormsProps { forms: { @@ -20,23 +21,6 @@ interface Top500FormsProps { handleChange: (value: Object) => void } -const getLocalizedMonthYearString = ( - month: number, - year: number, - locale: string -) => { - const dateForLocalization = new Date() - dateForLocalization.setDate(1) - dateForLocalization.setMonth(month) - dateForLocalization.setFullYear(year) - const localizedString = dateForLocalization.toLocaleString(locale, { - month: "long", - year: "numeric", - }) - - return localizedString.charAt(0).toUpperCase() + localizedString.slice(1) -} - const Top500Forms: React.FC = ({ forms, handleChange }) => { const { t, i18n } = useTranslation() const { themeColor } = useContext(MyThemeContext) diff --git a/frontend-react/src/components/xtrends/WeaponLineChart.tsx b/frontend-react/src/components/xtrends/WeaponLineChart.tsx index 8dae7ec28..20b8e32b0 100644 --- a/frontend-react/src/components/xtrends/WeaponLineChart.tsx +++ b/frontend-react/src/components/xtrends/WeaponLineChart.tsx @@ -3,6 +3,8 @@ import { LineChart, Line, Tooltip } from "recharts" import MyThemeContext from "../../themeContext" import { months } from "../../utils/lists" import { Box, Flex, Badge } from "@chakra-ui/core" +import { useTranslation } from "react-i18next" +import { parseAndGetLocalizedMonthYear } from "../../utils/helperFunctions" interface WeaponLineChartProps { counts: { @@ -66,11 +68,8 @@ const WeaponLineChart: React.FC = ({ ) } - const CustomTooltip: React.FC = ({ - active, - payload, - label, - }) => { + const CustomTooltip: React.FC = ({ active, payload }) => { + const { i18n } = useTranslation() if (active) { return ( = ({ border="1px solid" > - {payload[0].payload.name} + {parseAndGetLocalizedMonthYear( + payload[0].payload.name, + i18n.language + )} diff --git a/frontend-react/src/components/xtrends/XTrendsPage.tsx b/frontend-react/src/components/xtrends/XTrendsPage.tsx index 799fe1419..67aaaab83 100644 --- a/frontend-react/src/components/xtrends/XTrendsPage.tsx +++ b/frontend-react/src/components/xtrends/XTrendsPage.tsx @@ -22,6 +22,11 @@ import Select from "../elements/Select" import WeaponLineChart from "./WeaponLineChart" import { Helmet } from "react-helmet-async" import Alert from "../elements/Alert" +import { useTranslation } from "react-i18next" +import { + getLocalizedMonthYearString, + parseAndGetLocalizedMonthYear, +} from "../../utils/helperFunctions" const tiers = [ { @@ -71,7 +76,15 @@ const tiers = [ }, ] as const +const modeTranslationKey = new Map([ + ["SZ", "splatZonesShort"], + ["TC", "towerControlShort"], + ["RM", "rainMakerShort"], + ["CB", "clamBlitzShort"], +]) + const XTrendsPage: React.FC = () => { + const { t, i18n } = useTranslation() const { grayWithShade, darkerBgColor, themeColorWithShade } = useContext( MyThemeContext ) @@ -142,19 +155,25 @@ const XTrendsPage: React.FC = () => { <> - Top 500 Tier Lists | sendou.ink + {t("navigation;Top 500 Tier Lists")} | sendou.ink - - Here you can find X Rank Top 500 usage tier lists. For example for a - weapon to be in the X tier it needs at least 30 placements in that - mode that month. - + {t("xtrends;trendsExplanation")}