Refactor: locale-aware VMs, dictionary-driven views, and TopPage decomposition#303
Merged
zigzagdev merged 15 commits intochore/create-language-contextfrom May 2, 2026
Merged
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop the inline REGION_LABELS / CATEGORY_LABELS constants and pull every visible string (chip headings, placeholders, aria-labels, the search button) from useText. The empty option falls back to text.all; the other options reuse the existing categoryLabels / regionLabels dicts. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…onents
Pull TopPage's title row, items grid, and pagination block out into
TopPageTitleBar, HeritageList, and TopPagePagination. TopPage becomes a
thin slot-based shell taking { titleBar, header, content, pagination }
as ReactNodes; the container builds each subcomponent and wires them in.
The 13-field TopPage Props collapses to four ReactNode slots inlined
on the signature, so the named type is gone. Test mocks for TopPage and
its callers are retargeted at the new subcomponents.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pull the locale switch button (the flag toggle) out into a shared LocaleToggle component under shared/locale and use it in both HeritageDetailLayout and TopPageTitleBar instead of duplicating the inline button. The detail layout no longer needs useLocale directly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Add appTitle and appTagline keys to en/ja ui dictionaries and read them in TopPageTitleBar via useText, replacing the hardcoded "World Heritage" heading and "Learn by searching..." subheading. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Content
Localethrough the heritage VM mappers so English mode no longer falls back to Japanese strings, and addsdisplayName/displaySubName/displayDescriptionso view components can droptheir own
locale === "ja"branches.useText()dictionary; adds dictionary entries for bothenandja, plus per-value lookup tables forCategory(Cultural / Natural / Mixed) andRegion(Africa / Asia / Europe / …).TopPageintoTopPageTitleBar,HeritageList, andTopPagePagination, leavingTopPageas a thin slot-based shell with fourReactNodeslots and no namedPropstype. Extracts the locale flag toggle into a shared<LocaleToggle />and reuses it in both the top page and the detail layout.Propsplacement in.tsxfiles: dropsexport type ...PropsfromTopPage,HeritageSubHeader,HeritageMetadataList, andSearchResultsPage; renamesuseText()results fromttotextthroughout the detail components.Locale plumbing (mappers + hooks)
toWorldHeritageVm/toWorldHeritageDetailVm/toHeritageSearchResultVmnow take alocaleargument and resolvetitle,subtitle,country, and the newdisplaySubName/displayDescriptionfields per locale.
use-top-pageanduse-world-heritage-detailread locale viauseLocale()and feed it to the mappers;SearchHeritageResultsContainerdoes the same.to-world-heritage-detail-vm-test.tsto.test.tsso it actually runs in Jest, and updated assertions for the new signature.Dictionary-driven views
categoryLabelsandregionLabelslookup tables. ja labels follow common Japanese heritage-site wording (e.g.保有国,分類,遺産の面積,文化遺産/自然遺産/複合遺産).HeritageSidebar,HeritageDetailLayout(KeyExamInfo),HeritageHero,HeritageOverviewSection,HeritageSearchForm, andTopPageTitleBarnow read every label, placeholder, aria-label, and value fromuseText(). The brand stringWorld Heritageis intentionally left untranslated in ja.Structural cleanup
TopPageTitleBar,HeritageList,TopPagePagination,LocaleToggle.TopPagebecomes{ titleBar, header?, content, pagination? }ofReactNodes.TopPageContainernow constructs each subcomponent and wires it in.TopPageContainerretargeted at the new subcomponents.t→textforuseText()consumers.Notes
Asia,Cultural, …) used in the map popup andHeritageCardchip are still in English; out of scope for this PR.langquery param (e.g.?lang=ja); switching to a path prefix is tracked separately.Test plan
npm run typecheckpassesnpm testpasses (13 suites / 65 tests)/heritageswith?lang=jaand?lang=en, toggle via the newLocaleToggle, confirm header / search form / cards / detail panel / sidebar all switch./heritages/:id, confirm title / subtitle / overview / sidebar metadata are localized, and that the brandWorld Heritagestays English in both locales.このまま貼ればそのまま使えます。base ブランチは main 想定で書いてあります (もし develop 等なら適宜)。