Translate weapon pages

This commit is contained in:
Sakura Knoll
2022-01-08 20:31:09 +09:00 Unverified
parent 0fbbb45c80
commit 88f91c1a27
4 changed files with 44 additions and 13 deletions
+11
View File
@@ -39,5 +39,16 @@
"weapons-list": { "weapons-list": {
"weapons": "Weapons", "weapons": "Weapons",
"filter-by-category": "Filter by Category" "filter-by-category": "Filter by Category"
},
"weapons-show": {
"pistol": "Pistol",
"cannon": "Cannon",
"katana": "Katana",
"cross": "Cross",
"greatsword": "Greatsword",
"scythe": "Scythe",
"lance": "Lance",
"gauntlet": "Gauntlet",
"bow": "Bow"
} }
} }
+11
View File
@@ -42,5 +42,16 @@
"weapons-list": { "weapons-list": {
"weapons": "무기", "weapons": "무기",
"filter-by-category": "카테고리 필터" "filter-by-category": "카테고리 필터"
},
"weapons-show": {
"pistol": "쌍권총",
"cannon": "대포",
"katana": "태도",
"cross": "십자가",
"greatsword": "대검",
"scythe": "낫",
"lance": "랜스",
"gauntlet": "건틀릿",
"bow": "활"
} }
} }
+19 -9
View File
@@ -6,17 +6,23 @@ import Breadcrumb from '../../../components/organisms/Breadcrumb'
import Honkai3rdNavigator from '../../../components/organisms/Honkai3rdNavigator' import Honkai3rdNavigator from '../../../components/organisms/Honkai3rdNavigator'
import { WeaponData } from '../../../lib/honkai3rd/weapons' import { WeaponData } from '../../../lib/honkai3rd/weapons'
import { generateI18NPaths, getI18NProps } from '../../../server/i18n' import { generateI18NPaths, getI18NProps } from '../../../server/i18n'
import { capitalize } from '../../../lib/string'
import { import {
getWeaponById, getWeaponById,
listWeapons, listWeapons,
} from '../../../server/data/honkai3rd/weapons' } from '../../../server/data/honkai3rd/weapons'
import { useRouter } from 'next/router'
import { useTranslation, translate } from '../../../lib/i18n'
interface WeaponShowPageProps { interface WeaponShowPageProps {
weapon: WeaponData weapon: WeaponData
} }
const WeaponShowPage = ({ weapon }: WeaponShowPageProps) => { const WeaponShowPage = ({ weapon }: WeaponShowPageProps) => {
const { locale } = useRouter()
const { t } = useTranslation()
const weaponName = translate(locale, { 'ko-KR': weapon.krName }, weapon.name)
return ( return (
<Box> <Box>
<Honkai3rdNavigator /> <Honkai3rdNavigator />
@@ -24,28 +30,28 @@ const WeaponShowPage = ({ weapon }: WeaponShowPageProps) => {
<Box p={3}> <Box p={3}>
<Breadcrumb <Breadcrumb
items={[ items={[
{ href: '/honkai3rd', label: 'Honkai 3rd' }, { href: '/honkai3rd', label: t('breadcrumb.honkai-3rd') },
{ href: '/honkai3rd/weapons', label: 'Weapons' }, { href: '/honkai3rd/weapons', label: t('breadcrumb.weapons') },
{ {
href: `/honkai3rd/weapons/${weapon.id}`, href: `/honkai3rd/weapons/${weapon.id}`,
label: weapon.name, label: weaponName,
}, },
]} ]}
/> />
<Heading as='h1'>{weapon.name}</Heading> <Heading as='h1'>{weaponName}</Heading>
<Box mb={3}> <Box mb={3}>
<SquareImageBox <SquareImageBox
size={100} size={100}
alt={weapon.name} alt={weaponName}
src={`/assets/honkai3rd/weapons/${weapon.id}.png`} src={`/assets/honkai3rd/weapons/${weapon.id}.png`}
/> />
</Box> </Box>
<Card mb={3}> <Card mb={3}>
<Box p={2} sx={{ borderBottom: 'default' }}> <Box p={2} sx={{ borderBottom: 'default' }}>
{capitalize(weapon.category)} {t(`weapons-show.${weapon.category}`)}
</Box> </Box>
<Box p={2} sx={{ borderBottom: 'default' }}> <Box p={2} sx={{ borderBottom: 'default' }}>
{'⭐'.repeat(weapon.rarity)} {'⭐'.repeat(weapon.rarity)}
@@ -60,7 +66,7 @@ const WeaponShowPage = ({ weapon }: WeaponShowPageProps) => {
return ( return (
<Card key={skill.name} mb={3}> <Card key={skill.name} mb={3}>
<Heading as='h3' p={2} m={0} sx={{ borderBottom: 'default' }}> <Heading as='h3' p={2} m={0} sx={{ borderBottom: 'default' }}>
{skill.name} {translate(locale, { 'ko-KR': skill.krName }, skill.name)}
</Heading> </Heading>
<Paragraph <Paragraph
p={2} p={2}
@@ -68,7 +74,11 @@ const WeaponShowPage = ({ weapon }: WeaponShowPageProps) => {
whiteSpace: 'pre-wrap', whiteSpace: 'pre-wrap',
}} }}
> >
{skill.description} {translate(
locale,
{ 'ko-KR': skill.krDescription },
skill.description
)}
</Paragraph> </Paragraph>
</Card> </Card>
) )
+3 -4
View File
@@ -11,8 +11,7 @@ import { WeaponData } from '../../../lib/honkai3rd/weapons'
import WeaponCard from '../../../components/molecules/WeaponCard' import WeaponCard from '../../../components/molecules/WeaponCard'
import { getI18NProps } from '../../../server/i18n' import { getI18NProps } from '../../../server/i18n'
import { NextPageContext } from 'next' import { NextPageContext } from 'next'
import { useTranslation } from 'next-i18next' import { useTranslation, translate } from '../../../lib/i18n'
import { translate } from '../../../lib/i18n'
type WeaponListItemData = Pick< type WeaponListItemData = Pick<
WeaponData, WeaponData,
@@ -62,8 +61,8 @@ const WeaponListPage = ({ weaponDataList }: WeaponListPageProps) => {
<Box p={3}> <Box p={3}>
<Breadcrumb <Breadcrumb
items={[ items={[
{ href: '/honkai3rd', label: 'Honkai 3rd' }, { href: '/honkai3rd', label: t('breadcrumb.honkai-3rd') },
{ href: '/honkai3rd/weapons', label: 'Weapons' }, { href: '/honkai3rd/weapons', label: t('breadcrumb.weapons') },
]} ]}
/> />