diff --git a/client/src/app/features/top/cards/HeritageCard.tsx b/client/src/app/features/top/cards/HeritageCard.tsx index c1139a8..81857af 100644 --- a/client/src/app/features/top/cards/HeritageCard.tsx +++ b/client/src/app/features/top/cards/HeritageCard.tsx @@ -1,6 +1,8 @@ import type { ReactNode, MouseEvent } from "react"; import type { WorldHeritageVm, CriteriaCode } from "../../../../domain/types.ts"; import { BaseCard } from "@shared/uis/BaseCard.tsx"; +import { useLocale } from "@shared/locale/LocaleHooks.ts"; +import { useText } from "@shared/locale/ui-text.ts"; function MetaChip({ children }: { children: ReactNode }) { return ( @@ -40,6 +42,9 @@ export function HeritageCard({ item: WorldHeritageVm; onClickItem?: (id: number) => void; }) { + const { locale } = useLocale(); + const text = useText(); + const goDetail = () => { if (!onClickItem) return; onClickItem(item.id); @@ -54,7 +59,7 @@ export function HeritageCard({ goDetail(); }; - const title = item.heritageNameJp || "World Heritage"; + const title = locale === "ja" && item.heritageNameJp ? item.heritageNameJp : item.name; const subtitle = item.subtitle ?? ""; const desc = (item.shortDescription ?? "").trim(); @@ -74,7 +79,7 @@ export function HeritageCard({ /> ) : (
- No image + {text.noImage}
)} @@ -83,7 +88,7 @@ export function HeritageCard({ {item.isEndangered && (
- DANGER + {text.danger}
)} @@ -101,7 +106,7 @@ export function HeritageCard({ {item.category && (
- Heritage Category + {text.heritageCategory}
{item.category} @@ -112,7 +117,7 @@ export function HeritageCard({ {criteria.length > 0 && (
- Criteria + {text.criteria}
{criteria.map((c: CriteriaCode) => ( @@ -134,7 +139,7 @@ export function HeritageCard({ {desc}

) : ( -

No overview available.

+

{text.noOverview}

)}
diff --git a/client/src/app/features/top/components/heritage-detail/HeritageDetailLayout.tsx b/client/src/app/features/top/components/heritage-detail/HeritageDetailLayout.tsx index 7302450..fc565de 100644 --- a/client/src/app/features/top/components/heritage-detail/HeritageDetailLayout.tsx +++ b/client/src/app/features/top/components/heritage-detail/HeritageDetailLayout.tsx @@ -11,6 +11,7 @@ import { textType } from "@shared/styles/typography"; import { useSetBreadcrumbLabel } from "@features/breadcrumbs/BreadCrumbHooks.ts"; import { BreadcrumbList } from "@shared/components/BreadcrumbList.tsx"; import { useLocale } from "@shared/locale/LocaleHooks.ts"; +import { useText } from "@shared/locale/ui-text.ts"; const DEFAULT_SEARCH: SearchValues = { region: "", @@ -20,12 +21,6 @@ const DEFAULT_SEARCH: SearchValues = { yearInscribedTo: "", }; -const TABS: readonly { label: string; href: `#${string}` }[] = [ - { label: "Description", href: "#content" }, - { label: "Maps", href: "#geo-map" }, - { label: "Gallery", href: "#gallery" }, -] as const; - const formatCriteriaInline = (criteria: string[] | undefined) => criteria?.length ? criteria.map((c) => `(${c})`).join("") : "—"; @@ -59,30 +54,31 @@ function HeritageDetailTabs({ // Key exam info: visible without scrolling on all screen sizes. function KeyExamInfo({ item }: { item: WorldHeritageDetailVm }) { + const t = useText(); return (
- Region + {t.region}
{item.region ?? "—"}
- Category + {t.category}
{item.category ?? "—"}
- Year Inscribed + {t.yearInscribed}
{item.yearInscribed ?? "—"}
- Criteria + {t.criteria}
{formatCriteriaInline(item.criteria)} @@ -98,6 +94,12 @@ export function HeritageDetailLayout({ item }: { item: WorldHeritageDetailVm }) const setLabel = useSetBreadcrumbLabel(); const navigate = useNavigate(); const { locale, toggleLocale } = useLocale(); + const t = useText(); + const tabs: readonly { label: string; href: `#${string}` }[] = [ + { label: t.description, href: "#content" }, + { label: t.maps, href: "#geo-map" }, + { label: t.gallery, href: "#gallery" }, + ]; const handleSubmit = (q: Partial) => { const next = { ...search, ...q }; @@ -124,7 +126,7 @@ export function HeritageDetailLayout({ item }: { item: WorldHeritageDetailVm })
- +
diff --git a/client/src/locals/en/ui.json b/client/src/locals/en/ui.json new file mode 100644 index 0000000..04acca6 --- /dev/null +++ b/client/src/locals/en/ui.json @@ -0,0 +1,16 @@ +{ + "heritageCategory": "Heritage Category", + "criteria": "Criteria", + "viewDetails": "View details", + "danger": "DANGER", + "noImage": "No image", + "noOverview": "No overview available.", + "region": "Region", + "category": "Category", + "yearInscribed": "Year Inscribed", + "description": "Description", + "maps": "Maps", + "gallery": "Gallery", + "overview": "Overview", + "viewOnUnesco": "View on UNESCO" +} diff --git a/client/src/locals/ja/ui.json b/client/src/locals/ja/ui.json new file mode 100644 index 0000000..b44d404 --- /dev/null +++ b/client/src/locals/ja/ui.json @@ -0,0 +1,16 @@ +{ + "heritageCategory": "遺産カテゴリ", + "criteria": "登録基準", + "viewDetails": "詳細を見る", + "danger": "危機", + "noImage": "画像なし", + "noOverview": "概要はありません。", + "region": "地域", + "category": "カテゴリ", + "yearInscribed": "登録年", + "description": "説明", + "maps": "地図", + "gallery": "ギャラリー", + "overview": "概要", + "viewOnUnesco": "UNESCO で見る" +} diff --git a/client/src/shared/locale/ui-text.ts b/client/src/shared/locale/ui-text.ts new file mode 100644 index 0000000..29a9c43 --- /dev/null +++ b/client/src/shared/locale/ui-text.ts @@ -0,0 +1,13 @@ +import en from "../../locals/en/ui.json"; +import ja from "../../locals/ja/ui.json"; +import { type Locale } from "../../domain/criteria.ts"; +import { useLocale } from "./LocaleHooks.ts"; + +export type UiText = typeof en; + +const TEXTS: Record = { en, ja }; + +export const useText = (): UiText => { + const { locale } = useLocale(); + return TEXTS[locale]; +};