Localized saved teams

This commit is contained in:
Justin Edmund 2022-03-05 14:01:57 -08:00
parent 75f77ced20
commit 5a184ed8aa
5 changed files with 34 additions and 8 deletions

View file

@ -1,8 +1,10 @@
import React, { useCallback, useEffect, useState } from 'react' import React, { useCallback, useEffect, useState } from 'react'
import Head from 'next/head' import Head from 'next/head'
import { useRouter } from 'next/router'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import { useCookies } from 'react-cookie' 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' import api from '~utils/api'
@ -14,6 +16,7 @@ const ProfileRoute: React.FC = () => {
const router = useRouter() const router = useRouter()
const { username } = router.query const { username } = router.query
const { t } = useTranslation('common')
const [cookies] = useCookies(['account']) const [cookies] = useCookies(['account'])
const [found, setFound] = useState(false) const [found, setFound] = useState(false)
@ -170,7 +173,7 @@ const ProfileRoute: React.FC = () => {
</GridRepCollection> </GridRepCollection>
{ (parties.length == 0) ? { (parties.length == 0) ?
<div id="NotFound"> <div id="NotFound">
<h2>{ (loading) ? 'Loading teams...' : 'No teams found' }</h2> <h2>{ (loading) ? t('teams.loading') : t('teams.not_found') }</h2>
</div> </div>
: '' } : '' }
</section> </section>

View file

@ -1,8 +1,11 @@
import React, { useCallback, useEffect, useState } from 'react' import React, { useCallback, useEffect, useState } from 'react'
import Head from 'next/head' import Head from 'next/head'
import { useRouter } from 'next/router'
import { useCookies } from 'react-cookie' import { useCookies } from 'react-cookie'
import { useRouter } from 'next/router'
import { useTranslation } from 'next-i18next'
import clonedeep from 'lodash.clonedeep' import clonedeep from 'lodash.clonedeep'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import api from '~utils/api' import api from '~utils/api'
@ -12,6 +15,7 @@ import FilterBar from '~components/FilterBar'
const SavedRoute: React.FC = () => { const SavedRoute: React.FC = () => {
const router = useRouter() const router = useRouter()
const { t } = useTranslation('common')
// Cookies // Cookies
const [cookies] = useCookies(['account']) const [cookies] = useCookies(['account'])
@ -143,7 +147,7 @@ const SavedRoute: React.FC = () => {
return ( return (
<div id="Teams"> <div id="Teams">
<Head> <Head>
<title>Your saved Teams</title> <title>{t('saved.title')}</title>
<meta property="og:title" content="Your saved Teams" /> <meta property="og:title" content="Your saved Teams" />
<meta property="og:url" content="https://app.granblue.team/saved" /> <meta property="og:url" content="https://app.granblue.team/saved" />
@ -155,7 +159,7 @@ const SavedRoute: React.FC = () => {
</Head> </Head>
<FilterBar onFilter={receiveFilters} scrolled={scrolled}> <FilterBar onFilter={receiveFilters} scrolled={scrolled}>
<h1>Your saved Teams</h1> <h1>{t('saved.title')}</h1>
</FilterBar> </FilterBar>
<section> <section>
@ -182,7 +186,7 @@ const SavedRoute: React.FC = () => {
{ (parties.length == 0) ? { (parties.length == 0) ?
<div id="NotFound"> <div id="NotFound">
<h2>{ (loading) ? 'Loading saved teams...' : 'You haven&apos;t saved any teams yet' }</h2> <h2>{ (loading) ? t('saved.loading') : t('saved.not_found') }</h2>
</div> </div>
: '' } : '' }
</section> </section>
@ -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 export default SavedRoute

View file

@ -3,8 +3,8 @@ import Head from 'next/head'
import { useRouter } from 'next/router' import { useRouter } from 'next/router'
import { useCookies } from 'react-cookie' import { useCookies } from 'react-cookie'
import { useTranslation } from 'next-i18next' import { useTranslation } from 'next-i18next'
import { serverSideTranslations } from 'next-i18next/serverSideTranslations' import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
import clonedeep from 'lodash.clonedeep' import clonedeep from 'lodash.clonedeep'

View file

@ -132,6 +132,11 @@
"summons": "Summons" "summons": "Summons"
} }
}, },
"saved": {
"title": "Your saved Teams",
"loading": "Loading saved teams...",
"not_found": "You haven't saved any teams"
},
"teams": { "teams": {
"title": "Discover Teams", "title": "Discover Teams",
"loading": "Loading teams...", "loading": "Loading teams...",

View file

@ -133,6 +133,11 @@
"summons": "召喚石" "summons": "召喚石"
} }
}, },
"saved": {
"title": "保存した編成",
"loading": "ロード中...",
"not_found": "編成はまだ保存していません"
},
"teams": { "teams": {
"title": "編成一覧", "title": "編成一覧",
"loading": "ロード中...", "loading": "ロード中...",