Introduce i18n

This commit is contained in:
Sakura Knoll
2022-01-03 13:22:37 +09:00 Unverified
parent d6a8a0e7b0
commit 8bc576208a
20 changed files with 198 additions and 58 deletions
+8 -5
View File
@@ -5,6 +5,7 @@ import SquareImageBox from '../../../components/atoms/SquareImageBox'
import Breadcrumb from '../../../components/organisms/Breadcrumb'
import Honkai3rdNavigator from '../../../components/organisms/Honkai3rdNavigator'
import { WeaponData } from '../../../lib/honkai3rd/weapons'
import { getI18NProps } from '../../../lib/i18n'
import { capitalize } from '../../../lib/string'
import {
getWeaponById,
@@ -80,12 +81,14 @@ const WeaponShowPage = ({ weapon }: WeaponShowPageProps) => {
export default WeaponShowPage
export function getStaticProps(
context: NextPageContext & { params: { weaponId: string } }
) {
const weapon = getWeaponById(context.params.weaponId)
export async function getStaticProps({
params,
locale,
}: NextPageContext & { params: { weaponId: string } }) {
const weapon = getWeaponById(params.weaponId)
return {
props: { weapon },
props: { weapon, ...(await getI18NProps(locale)) },
}
}
+4 -1
View File
@@ -9,6 +9,8 @@ import FilterButton from '../../../components/atoms/FilterButton'
import { useRouter } from 'next/router'
import { WeaponData } from '../../../lib/honkai3rd/weapons'
import WeaponCard from '../../../components/molecules/WeaponCard'
import { getI18NProps } from '../../../lib/i18n'
import { NextPageContext } from 'next'
type WeaponListItemData = Pick<
WeaponData,
@@ -94,12 +96,13 @@ const WeaponListPage = ({ weaponDataList }: WeaponListPageProps) => {
export default WeaponListPage
export async function getStaticProps() {
export async function getStaticProps({ locale }: NextPageContext) {
return {
props: {
weaponDataList: listWeapons().map((weapon) => {
return pick(['name', 'id', 'rarity', 'category'], weapon)
}),
...(await getI18NProps(locale)),
},
}
}