-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fix homepage localization for chip labels and translations #2275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 9 commits
7459aba
f026e56
0723732
6244913
bba7388
7f9a7cb
26fa6d9
16ab5d8
9199903
465819d
0c53dcf
cfde794
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| import type { ProjectKind, ProjectMetadata } from '@open-design/contracts'; | ||
| import type { DefaultScenarioPluginId } from '@open-design/contracts'; | ||
| import type { IconName } from '../Icon'; | ||
| import type { Dict } from '../../i18n/types'; | ||
|
|
||
| // Plugin ids the chip rail can dispatch to. Most chips route to a | ||
| // `DefaultScenarioPluginId` so the same fallback table the daemon | ||
|
|
@@ -33,7 +34,8 @@ import type { IconName } from '../Icon'; | |
| // independently of the default-binding mapping. | ||
| export type ChipScenarioPluginId = | ||
| | DefaultScenarioPluginId | ||
| | 'example-hyperframes'; | ||
| | 'example-hyperframes' | ||
| | 'example-live-artifact'; | ||
|
|
||
| export type ChipAction = | ||
| | { | ||
|
|
@@ -60,19 +62,29 @@ export type ChipAction = | |
| // narrow viewports without horizontal scrolling. | ||
| export type ChipGroup = 'create' | 'migrate'; | ||
|
|
||
| export interface HomeHeroChip { | ||
| export interface CreateChip { | ||
| id: string; | ||
| label: string; | ||
| icon: IconName; | ||
| group: ChipGroup; | ||
| labelKey: keyof Dict; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change makes |
||
| hint?: string; | ||
| icon: IconName; | ||
| group: 'create'; | ||
| action: ChipAction; | ||
| } | ||
|
|
||
| export interface MigrateChip { | ||
| id: string; | ||
| icon: IconName; | ||
| group: 'migrate'; | ||
| hint: string; | ||
| action: ChipAction; | ||
| } | ||
|
|
||
| export type HomeHeroChip = CreateChip | MigrateChip; | ||
|
|
||
| export const HOME_HERO_CHIPS: ReadonlyArray<HomeHeroChip> = [ | ||
| { | ||
| id: 'prototype', | ||
| label: 'Prototype', | ||
| labelKey: 'homeHero.chip.prototype', | ||
| icon: 'palette', | ||
| group: 'create', | ||
| // Prototype now binds to the bundled `example-web-prototype` plugin, | ||
|
|
@@ -92,7 +104,7 @@ export const HOME_HERO_CHIPS: ReadonlyArray<HomeHeroChip> = [ | |
| }, | ||
| { | ||
| id: 'live-artifact', | ||
| label: 'Live artifact', | ||
| labelKey: 'homeHero.chip.liveArtifact', | ||
| icon: 'refresh', | ||
| group: 'create', | ||
| hint: 'Build a refreshable artifact backed by connector or local data.', | ||
|
|
@@ -109,7 +121,7 @@ export const HOME_HERO_CHIPS: ReadonlyArray<HomeHeroChip> = [ | |
| }, | ||
| { | ||
| id: 'deck', | ||
| label: 'Slide deck', | ||
| labelKey: 'homeHero.chip.deck', | ||
| icon: 'present', | ||
| group: 'create', | ||
| // Slide deck binds to `example-simple-deck`, which ships a 353-line | ||
|
|
@@ -130,7 +142,7 @@ export const HOME_HERO_CHIPS: ReadonlyArray<HomeHeroChip> = [ | |
| }, | ||
| { | ||
| id: 'image', | ||
| label: 'Image', | ||
| labelKey: 'homeHero.chip.image', | ||
| icon: 'image', | ||
| group: 'create', | ||
| action: { | ||
|
|
@@ -147,7 +159,7 @@ export const HOME_HERO_CHIPS: ReadonlyArray<HomeHeroChip> = [ | |
| }, | ||
| { | ||
| id: 'video', | ||
| label: 'Video', | ||
| labelKey: 'homeHero.chip.video', | ||
| icon: 'play', | ||
| group: 'create', | ||
| action: { | ||
|
|
@@ -164,7 +176,7 @@ export const HOME_HERO_CHIPS: ReadonlyArray<HomeHeroChip> = [ | |
| }, | ||
| { | ||
| id: 'hyperframes', | ||
| label: 'HyperFrames', | ||
| labelKey: 'homeHero.chip.hyperframes', | ||
| icon: 'orbit', | ||
| group: 'create', | ||
| hint: 'Author HTML-based motion: captions, audio-reactive visuals, scene transitions.', | ||
|
|
@@ -176,7 +188,7 @@ export const HOME_HERO_CHIPS: ReadonlyArray<HomeHeroChip> = [ | |
| }, | ||
| { | ||
| id: 'audio', | ||
| label: 'Audio', | ||
| labelKey: 'homeHero.chip.audio', | ||
| icon: 'mic', | ||
| group: 'create', | ||
| action: { | ||
|
|
@@ -193,15 +205,13 @@ export const HOME_HERO_CHIPS: ReadonlyArray<HomeHeroChip> = [ | |
| }, | ||
| { | ||
| id: 'create-plugin', | ||
| label: 'Create plugin', | ||
| icon: 'edit', | ||
| group: 'migrate', | ||
| hint: 'Author a reusable Open Design plugin and add it to My plugins.', | ||
| action: { kind: 'create-plugin' }, | ||
| }, | ||
| { | ||
| id: 'figma', | ||
| label: 'From Figma', | ||
| icon: 'import', | ||
| group: 'migrate', | ||
| hint: 'Migrate a Figma frame into the active design system.', | ||
|
|
@@ -217,7 +227,6 @@ export const HOME_HERO_CHIPS: ReadonlyArray<HomeHeroChip> = [ | |
| }, | ||
| { | ||
| id: 'template', | ||
| label: 'From template', | ||
| icon: 'file-code', | ||
| group: 'migrate', | ||
| hint: 'Start from a bundled template.', | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,7 @@ import { cleanup, fireEvent, render, screen } from '@testing-library/react'; | |
| import { afterEach, describe, expect, it, vi } from 'vitest'; | ||
| import type { InstalledPluginRecord } from '@open-design/contracts'; | ||
|
|
||
| import { I18nProvider } from '../../src/i18n'; | ||
| import { HomeHero } from '../../src/components/HomeHero'; | ||
| import { | ||
| HOME_HERO_CHIPS, | ||
|
|
@@ -246,4 +247,38 @@ describe('HomeHero intent rail', () => { | |
| }, | ||
| }); | ||
| }); | ||
|
|
||
| it('renders localized chip labels and tooltips in zh-CN', () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This regression test only asserts one always-visible create-chip label ( |
||
| render( | ||
| <I18nProvider initial="zh-CN"> | ||
| <HomeHero | ||
| prompt="" | ||
| onPromptChange={() => undefined} | ||
| onSubmit={() => undefined} | ||
| activePluginTitle={null} | ||
| activeChipId={null} | ||
| onClearActivePlugin={() => undefined} | ||
| pluginOptions={[]} | ||
| pluginsLoading={false} | ||
| pendingPluginId={null} | ||
| pendingChipId={null} | ||
| onPickPlugin={vi.fn()} | ||
| onPickChip={vi.fn()} | ||
| contextItemCount={0} | ||
| error={null} | ||
| /> | ||
| </I18nProvider> | ||
| ); | ||
|
|
||
| // Prototype chip label should be zh-CN | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This zh-CN regression test still skips the other always-visible create chip, |
||
| const prototypeChip = screen.getByTestId('home-hero-rail-prototype'); | ||
| expect(prototypeChip.textContent).toContain('原型'); | ||
|
|
||
| // HyperFrames tooltip should be the zh-CN string | ||
| const hyperframes = screen.getByTestId('home-hero-rail-hyperframes'); | ||
| expect(hyperframes.getAttribute('title')).toBe( | ||
| '创作基于 HTML 的动态内容:字幕、音频响应视觉和场景转场。' | ||
| ); | ||
| }); | ||
|
|
||
| }); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔁 Powered by Looper · runner=reviewer · agent=opencode · An autonomous AI dev team for your GitHub repos.labelKeyis now type-safe here, but the lower rail still does not read it:RailGrouprendershomeHeroChipLabel(chip.id, t)inapps/web/src/components/HomeHero.tsx:1587, andhomeHeroChipTitle()also switches onchip.idfor the migrate chips atapps/web/src/components/HomeHero.tsx:1616-1619. That means the new metadata entries you changed here (create-plugin,figma,folder,template) are not actually the source of truth for the labels/tooltips users see in that rail. This matters because future homepage i18n edits can compile cleanly while silently updating only one of the two paths. Please either drive both rail labels/titles from chip metadata (for examplelabelKeyplus a typed hint/title key) or keep the switch helpers as the single source of truth and drop the unused migrate-chiplabelKeyfields.