From 88f91c1a276bd29c65eb6c00b8bcd37e8e0b6013 Mon Sep 17 00:00:00 2001 From: Sakura Knoll Date: Sat, 8 Jan 2022 20:31:09 +0900 Subject: [PATCH] Translate weapon pages --- public/locales/en-US/common.json | 11 +++++++++ public/locales/ko-KR/common.json | 11 +++++++++ src/pages/honkai3rd/weapons/[weaponId].tsx | 28 +++++++++++++++------- src/pages/honkai3rd/weapons/index.tsx | 7 +++--- 4 files changed, 44 insertions(+), 13 deletions(-) diff --git a/public/locales/en-US/common.json b/public/locales/en-US/common.json index 87ca314c..e0bf89ae 100644 --- a/public/locales/en-US/common.json +++ b/public/locales/en-US/common.json @@ -39,5 +39,16 @@ "weapons-list": { "weapons": "Weapons", "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" } } diff --git a/public/locales/ko-KR/common.json b/public/locales/ko-KR/common.json index facc07a6..ee35d714 100644 --- a/public/locales/ko-KR/common.json +++ b/public/locales/ko-KR/common.json @@ -42,5 +42,16 @@ "weapons-list": { "weapons": "무기", "filter-by-category": "카테고리 필터" + }, + "weapons-show": { + "pistol": "쌍권총", + "cannon": "대포", + "katana": "태도", + "cross": "십자가", + "greatsword": "대검", + "scythe": "낫", + "lance": "랜스", + "gauntlet": "건틀릿", + "bow": "활" } } diff --git a/src/pages/honkai3rd/weapons/[weaponId].tsx b/src/pages/honkai3rd/weapons/[weaponId].tsx index 091a9f96..ae78ee36 100644 --- a/src/pages/honkai3rd/weapons/[weaponId].tsx +++ b/src/pages/honkai3rd/weapons/[weaponId].tsx @@ -6,17 +6,23 @@ import Breadcrumb from '../../../components/organisms/Breadcrumb' import Honkai3rdNavigator from '../../../components/organisms/Honkai3rdNavigator' import { WeaponData } from '../../../lib/honkai3rd/weapons' import { generateI18NPaths, getI18NProps } from '../../../server/i18n' -import { capitalize } from '../../../lib/string' import { getWeaponById, listWeapons, } from '../../../server/data/honkai3rd/weapons' +import { useRouter } from 'next/router' +import { useTranslation, translate } from '../../../lib/i18n' interface WeaponShowPageProps { weapon: WeaponData } const WeaponShowPage = ({ weapon }: WeaponShowPageProps) => { + const { locale } = useRouter() + const { t } = useTranslation() + + const weaponName = translate(locale, { 'ko-KR': weapon.krName }, weapon.name) + return ( @@ -24,28 +30,28 @@ const WeaponShowPage = ({ weapon }: WeaponShowPageProps) => { - {weapon.name} + {weaponName} - {capitalize(weapon.category)} + {t(`weapons-show.${weapon.category}`)} {'⭐'.repeat(weapon.rarity)} @@ -60,7 +66,7 @@ const WeaponShowPage = ({ weapon }: WeaponShowPageProps) => { return ( - {skill.name} + {translate(locale, { 'ko-KR': skill.krName }, skill.name)} { whiteSpace: 'pre-wrap', }} > - {skill.description} + {translate( + locale, + { 'ko-KR': skill.krDescription }, + skill.description + )} ) diff --git a/src/pages/honkai3rd/weapons/index.tsx b/src/pages/honkai3rd/weapons/index.tsx index ca91f37c..14a9ec05 100644 --- a/src/pages/honkai3rd/weapons/index.tsx +++ b/src/pages/honkai3rd/weapons/index.tsx @@ -11,8 +11,7 @@ import { WeaponData } from '../../../lib/honkai3rd/weapons' import WeaponCard from '../../../components/molecules/WeaponCard' import { getI18NProps } from '../../../server/i18n' import { NextPageContext } from 'next' -import { useTranslation } from 'next-i18next' -import { translate } from '../../../lib/i18n' +import { useTranslation, translate } from '../../../lib/i18n' type WeaponListItemData = Pick< WeaponData, @@ -62,8 +61,8 @@ const WeaponListPage = ({ weaponDataList }: WeaponListPageProps) => {