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 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 = () => {
</GridRepCollection>
{ (parties.length == 0) ?
<div id="NotFound">
<h2>{ (loading) ? 'Loading teams...' : 'No teams found' }</h2>
<h2>{ (loading) ? t('teams.loading') : t('teams.not_found') }</h2>
</div>
: '' }
</section>

View file

@ -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 (
<div id="Teams">
<Head>
<title>Your saved Teams</title>
<title>{t('saved.title')}</title>
<meta property="og:title" content="Your saved Teams" />
<meta property="og:url" content="https://app.granblue.team/saved" />
@ -155,7 +159,7 @@ const SavedRoute: React.FC = () => {
</Head>
<FilterBar onFilter={receiveFilters} scrolled={scrolled}>
<h1>Your saved Teams</h1>
<h1>{t('saved.title')}</h1>
</FilterBar>
<section>
@ -182,7 +186,7 @@ const SavedRoute: React.FC = () => {
{ (parties.length == 0) ?
<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>
: '' }
</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

View file

@ -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'

View file

@ -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...",

View file

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