From 5a184ed8aa81b61b3de0e8cc317b4ada391902d3 Mon Sep 17 00:00:00 2001 From: Justin Edmund Date: Sat, 5 Mar 2022 14:01:57 -0800 Subject: [PATCH] Localized saved teams --- pages/[username].tsx | 9 ++++++--- pages/saved.tsx | 21 +++++++++++++++++---- pages/teams.tsx | 2 +- public/locales/en/common.json | 5 +++++ public/locales/ja/common.json | 5 +++++ 5 files changed, 34 insertions(+), 8 deletions(-) diff --git a/pages/[username].tsx b/pages/[username].tsx index 46b34e34..5a3d4243 100644 --- a/pages/[username].tsx +++ b/pages/[username].tsx @@ -1,8 +1,10 @@ import React, { useCallback, useEffect, useState } from 'react' import Head from 'next/head' -import { useRouter } from 'next/router' -import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import { useCookies } from 'react-cookie' +import { useRouter } from 'next/router' +import { useTranslation } from 'next-i18next' + +import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import api from '~utils/api' @@ -14,6 +16,7 @@ const ProfileRoute: React.FC = () => { const router = useRouter() const { username } = router.query + const { t } = useTranslation('common') const [cookies] = useCookies(['account']) const [found, setFound] = useState(false) @@ -170,7 +173,7 @@ const ProfileRoute: React.FC = () => { { (parties.length == 0) ?
-

{ (loading) ? 'Loading teams...' : 'No teams found' }

+

{ (loading) ? t('teams.loading') : t('teams.not_found') }

: '' } diff --git a/pages/saved.tsx b/pages/saved.tsx index 44811d0c..d42b5627 100644 --- a/pages/saved.tsx +++ b/pages/saved.tsx @@ -1,8 +1,11 @@ import React, { useCallback, useEffect, useState } from 'react' import Head from 'next/head' -import { useRouter } from 'next/router' import { useCookies } from 'react-cookie' +import { useRouter } from 'next/router' +import { useTranslation } from 'next-i18next' + import clonedeep from 'lodash.clonedeep' +import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import api from '~utils/api' @@ -12,6 +15,7 @@ import FilterBar from '~components/FilterBar' const SavedRoute: React.FC = () => { const router = useRouter() + const { t } = useTranslation('common') // Cookies const [cookies] = useCookies(['account']) @@ -143,7 +147,7 @@ const SavedRoute: React.FC = () => { return (
- Your saved Teams + {t('saved.title')} @@ -155,7 +159,7 @@ const SavedRoute: React.FC = () => { -

Your saved Teams

+

{t('saved.title')}

@@ -182,7 +186,7 @@ const SavedRoute: React.FC = () => { { (parties.length == 0) ?
-

{ (loading) ? 'Loading saved teams...' : 'You haven't saved any teams yet' }

+

{ (loading) ? t('saved.loading') : t('saved.not_found') }

: '' }
@@ -190,4 +194,13 @@ const SavedRoute: React.FC = () => { ) } +export async function getStaticProps({ locale }: { locale: string }) { + return { + props: { + ...(await serverSideTranslations(locale, ['common'])), + // Will be passed to the page component as props + }, + } +} + export default SavedRoute \ No newline at end of file diff --git a/pages/teams.tsx b/pages/teams.tsx index 55b115c3..2a513939 100644 --- a/pages/teams.tsx +++ b/pages/teams.tsx @@ -3,8 +3,8 @@ import Head from 'next/head' import { useRouter } from 'next/router' import { useCookies } from 'react-cookie' - import { useTranslation } from 'next-i18next' + import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import clonedeep from 'lodash.clonedeep' diff --git a/public/locales/en/common.json b/public/locales/en/common.json index 8620f84a..191ab614 100644 --- a/public/locales/en/common.json +++ b/public/locales/en/common.json @@ -132,6 +132,11 @@ "summons": "Summons" } }, + "saved": { + "title": "Your saved Teams", + "loading": "Loading saved teams...", + "not_found": "You haven't saved any teams" + }, "teams": { "title": "Discover Teams", "loading": "Loading teams...", diff --git a/public/locales/ja/common.json b/public/locales/ja/common.json index e77619e9..f4018399 100644 --- a/public/locales/ja/common.json +++ b/public/locales/ja/common.json @@ -133,6 +133,11 @@ "summons": "召喚石" } }, + "saved": { + "title": "保存した編成", + "loading": "ロード中...", + "not_found": "編成はまだ保存していません" + }, "teams": { "title": "編成一覧", "loading": "ロード中...",