From ec38b801471b0905d13a3757ec55574c721daeda Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Sat, 13 Aug 2022 12:39:08 +0300 Subject: [PATCH] Add translations --- TODO.md | 2 +- app/components/FormErrors.tsx | 8 ++-- app/routes/calendar/$id/index.tsx | 36 ++++++++++-------- app/routes/calendar/$id/report-winners.tsx | 43 +++++++++++++--------- app/routes/calendar/index.tsx | 31 ++++++++-------- app/routes/calendar/new.tsx | 36 ++++++++++-------- app/routes/u.$identifier/results.tsx | 4 +- app/styles/utils.css | 4 ++ public/locales/en/calendar.json | 42 +++++++++++++++++++++ public/locales/en/common.json | 9 ++++- 10 files changed, 144 insertions(+), 71 deletions(-) diff --git a/TODO.md b/TODO.md index 6c9df2402..fe0ea2a0e 100644 --- a/TODO.md +++ b/TODO.md @@ -19,7 +19,7 @@ Calendar - [x] Winners on the event info page - [x] There should be a banner on the list page if you have past tournaments to report - [x] On the user page tab showing past results -- [ ] Translations +- [x] Translations ## Other diff --git a/app/components/FormErrors.tsx b/app/components/FormErrors.tsx index 2e00a7dd6..366e9ecbf 100644 --- a/app/components/FormErrors.tsx +++ b/app/components/FormErrors.tsx @@ -1,6 +1,8 @@ import { useActionData } from "@remix-run/react"; +import { useTranslation } from "react-i18next"; -export function FormErrors() { +export function FormErrors({ namespace }: { namespace: "calendar" }) { + const { t } = useTranslation(["common", namespace]); const actionData = useActionData<{ errors?: string[] }>(); if (!actionData?.errors || actionData.errors.length === 0) { @@ -9,10 +11,10 @@ export function FormErrors() { return (
-

Following errors need to be fixed:

+

{t("common:forms.errors.title")}:

    {actionData.errors.map((error) => ( -
  1. {error}
  2. +
  3. {t(`${namespace}:${error}` as any)}
  4. ))}
diff --git a/app/routes/calendar/$id/index.tsx b/app/routes/calendar/$id/index.tsx index 577ab7c94..4f77cd126 100644 --- a/app/routes/calendar/$id/index.tsx +++ b/app/routes/calendar/$id/index.tsx @@ -73,7 +73,7 @@ export const loader = async ({ params, request }: LoaderArgs) => { export default function CalendarEventPage() { const user = useUser(); const data = useLoaderData(); - const { i18n } = useTranslation(); + const { i18n, t } = useTranslation(["common", "calendar"]); const isMounted = useIsMounted(); return ( @@ -87,7 +87,9 @@ export default function CalendarEventPage() { hidden: data.event.startTimes.length === 1, })} > - Day {i + 1} + {t("calendar:day", { + number: i + 1, + })}