Skip to content

Commit 305fe60

Browse files
fix(i18n): the full search page names component, doc and link results in every language (#36974)
<!-- claude-projects-attribution: {"github_login":"os-support-ai"} --> _Requested by **Yibo Wang** · [project thread](https://claude.ai/code/project/chan_01BVUyyPie8gHwoPM18iABwB?thread=cmsg_01BVUyyPie8gHwoPM18iABwBP9pYn3ZkhGT2R2hstwEY6w)_ repo:objectstack#3 · os-support-ai · session_01WGufzh1FMUQYf1PcEunaaK Fixes #36955 Clause-②: no Metadata-protocol: none ## 维护者速读 - 控制台用户打开完整搜索页时,组件、文档和链接类结果的分组标题与标签从原始键名变成各语言的正常文字,搜索框提示也提到组件和文档。 - 属于控制台体验修复,替在应用导航里放了审批收件箱、服务手册这类入口的用户解决看不懂的标题。 - 出错时最多是某个分组标题仍显示英文或键名,不影响搜索和跳转,可直接撤回。 - 无。 ## What changes - `ui/packages/i18n/src/locales/*.ts` (all eleven console packs; `zh-Hant.ts` regenerated with `gen:zh-hant` from `zh-Hans.ts`): the `search` block gains `typeComponents`, `typeDocs`, `typeUrls` and `badgeComponent`, `badgeDoc`, `badgeUrl`; `placeholder` and its twin `inputAriaLabel` now also name components and docs. - **`typeUrls` / `badgeUrl` go beyond the card's four keys, declared here:** the page derives `search.type` + Type + `s` from every listed nav item, and a `type: 'url'` item resolves to its own href (not `#`), so it is listed and printed `search.typeUrls` / `search.badgeUrl` the same way. Same defect class, same block, same gate family; the new pin goes red without them (mutation below). - `ui/packages/app-shell/src/views/__tests__/SearchResultsPage.resultTypeKeys-36955.test.tsx` (new): renders the page with one nav item of every spec nav type (read from `NavigationItemTypeSchema`, which is read off `@objectstack/spec`), each carrying every target field, so the page's own `resolveHref` decides which types are listed; collects every `search.type…` / `search.badge…` key the page asks `t` for and asserts each is a non-empty string in every built-in pack. No hand-written type or key list. - Gate-forced follow-ons of the placeholder change (claim surface amended for them): `SearchResultsPage.tsx` widens `SearchResult['type']` with `'component' | 'doc' | 'url'` (check-i18n-dead-keys one-hop leg reads that union as the badge discriminator); `global-search-renderer.tsx` inline `defaultValue`s of `search.placeholder` / `search.inputAriaLabel` follow the new en text (check-i18n-call-site-keys default-value drift); `ui/scripts/i18n-en-drift-baseline.json` drops the `search.placeholder` waiver, now stale because all ten translations follow the en change here (check-i18n-en-drift). - Changeset: `@object-ui/i18n` patch, `@object-ui/app-shell` patch (private). **Read first:** `ui/packages/app-shell/src/views/__tests__/SearchResultsPage.resultTypeKeys-36955.test.tsx` (the derivation; its non-vacuity case), then `ui/packages/i18n/src/locales/ru.ts` and `ar.ts` search blocks (genitive / Arabic list wording). **Two-minute check:** `cd ui && pnpm exec vitest run packages/app-shell/src/views/__tests__/SearchResultsPage.resultTypeKeys-36955.test.tsx` — expect 12 passed (1 non-vacuity case + 11 packs). ## Tests <details><summary>New pin, green at HEAD</summary> ``` Test Files 1 passed (1) Tests 12 passed (12) os-verify-lock: VERDICT command-exit 0 ``` </details> <details><summary>Mutation (one-shot, not kept): drop ru badgeUrl</summary> Ran through `scripts/ablation-replace.mjs` (anchor x1 to x0, blob df16126 to e7498ebd3155), restored to the HEAD blob df16126, `git diff HEAD` empty afterwards. ``` × ru names every heading and badge the page asks for AssertionError: expected [ 'search.badgeUrl' ] to deeply equal [] Tests 1 failed | 11 passed (12) ``` </details> <details><summary>@object-ui/i18n test + type-check</summary> ``` pnpm --filter @object-ui/i18n test Test Files 110 passed (110) · Tests 2026 passed | 13 skipped pnpm --filter @object-ui/i18n type-check VERDICT command-exit 0 ``` </details> ## Acceptance notes - The page's `SearchResult['type']` union, `TYPE_ICONS` and `TYPE_COLORS` still list only object/dashboard/page/report, so component, doc and link results render with the fallback database icon and no badge colour. Cosmetic, not in this card's surface; noted, not filed. - `global-search-renderer.tsx` (the `global:search` record-search block) shares `search.placeholder` / `search.inputAriaLabel` with the full search page, so its placeholder now also names components and docs, which a record search does not return (it already named dashboards, pages and reports, which it also does not return). Noted, not filed. ## Verification See the report comment on #36955 for the local gate list and its exit codes; CI runs the rest. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01WGufzh1FMUQYf1PcEunaaK --- ## Round 2 (after pr_create, head 9df9b39) - Claim amendments 7131602500 and 7133172172 cover the files beyond the first surface: `global-search-renderer.tsx` (inline `defaultValue` of `search.placeholder` / `search.inputAriaLabel` follows the new en text), `ui/scripts/i18n-en-drift-baseline.json` (stale `search.placeholder` waiver dropped), the `SearchResult['type']` union in `SearchResultsPage.tsx` (`'component' | 'doc' | 'url'`), and two one-line test edits forced by them: `ui/scripts/__tests__/check-i18n-en-drift.test.ts` (`WAIVER_CEILING` 7 → 6) and `global-page-blocks.render.test.tsx` (finds the `global:search` box by its new accessible name). - Line budget: 18 files, +247/−32 (one PR for the card). _Generated by [Claude Code](https://claude.ai/code/session_01WGufzh1FMUQYf1PcEunaaK)_ <!-- signed: repo:objectstack#3 · os-support-ai · session_01WGufzh1FMUQYf1PcEunaaK --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent c75453e commit 305fe60

18 files changed

Lines changed: 247 additions & 32 deletions
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
'@object-ui/i18n': patch
3+
'@object-ui/app-shell': patch
4+
---
5+
6+
fix(i18n): the full search page names component, doc and link results in every language
7+
8+
Clause-②: no
9+
Metadata-protocol: none
10+
11+
The console's full search page (opened from the command palette's "Open Full Search Page") titles each result group and badges each result by the navigation item's type. Component items, doc items and link items printed raw keys (`search.typeComponents`, `search.badgeDoc`, `search.typeUrls`, …) because no locale pack defined them, English included. Every shipped console locale pack now carries a heading and a badge for the three types, and the search placeholder and its accessible label also name components and docs. A new test in `@object-ui/app-shell` renders the page with one navigation item of every spec type and fails when any heading or badge key the page asks for is missing from a pack.

‎ui/packages/app-shell/src/views/SearchResultsPage.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ interface SearchResult {
4040
id: string;
4141
label: string;
4242
href: string;
43-
type: 'object' | 'dashboard' | 'page' | 'report';
43+
type: 'object' | 'dashboard' | 'page' | 'report' | 'component' | 'doc' | 'url';
4444
description?: string;
4545
}
4646

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
/**
2+
* ObjectUI
3+
* Copyright (c) 2024-present ObjectStack Inc.
4+
*
5+
* This source code is licensed under the MIT license found in the
6+
* LICENSE file in the root directory of this source tree.
7+
*/
8+
9+
/**
10+
* objectstack#36955 — every result type the full search page can emit has a
11+
* group heading (`search.type<Type>s`) and a badge (`search.badge<Type>`) in
12+
* every shipped locale pack.
13+
*
14+
* The page derives both keys from the nav item's `type` at render time, so a
15+
* type the packs do not name prints its raw key. Component and doc items did
16+
* exactly that (`search.typeComponents`, `search.badgeDoc`, …) while objects,
17+
* dashboards, pages and reports were translated.
18+
*
19+
* ⭐ Neither the type list nor the key list is written down here. The types come
20+
* from the spec's nav-item discriminator (`NavigationItemTypeSchema`, read off
21+
* `@objectstack/spec`); the page is rendered with one item of EVERY type, each
22+
* carrying every target field, and the page itself decides which survive (its
23+
* `resolveHref` drops the ones that link nowhere). The keys are the ones the
24+
* page then asks `t` for. A new nav type that the page lists, or a new key
25+
* derivation, is measured without an edit to this file.
26+
*/
27+
28+
import { describe, it, expect, vi } from 'vitest';
29+
import { render } from '@testing-library/react';
30+
import React from 'react';
31+
import { NavigationItemTypeSchema } from '@object-ui/types/zod';
32+
import { builtInLocales } from '@object-ui/i18n/locales';
33+
34+
/** Every key the component asked `t` for during the render. */
35+
const asked = vi.hoisted(() => ({ keys: [] as string[] }));
36+
const app = vi.hoisted(() => ({ navigation: [] as unknown[] }));
37+
38+
vi.mock('react-router-dom', () => ({
39+
useParams: () => ({ appName: 'crm' }),
40+
useSearchParams: () => [new URLSearchParams(''), vi.fn()],
41+
Link: ({ to, children, ...rest }: any) => (
42+
<a href={typeof to === 'string' ? to : ''} {...rest}>
43+
{children}
44+
</a>
45+
),
46+
}));
47+
48+
vi.mock('@object-ui/i18n', async (importOriginal) => {
49+
const actual = await importOriginal<any>();
50+
return {
51+
...actual,
52+
useObjectTranslation: () => ({
53+
t: (key: string) => {
54+
asked.keys.push(key);
55+
return key;
56+
},
57+
language: 'en',
58+
}),
59+
};
60+
});
61+
62+
vi.mock('@object-ui/react', async (importOriginal) => ({
63+
...(await importOriginal<Record<string, unknown>>()),
64+
useRecordSearch: () => ({ results: [], isSearching: false, error: undefined }),
65+
}));
66+
67+
vi.mock('../../providers/MetadataProvider', () => ({
68+
useMetadata: () => ({
69+
apps: [{ name: 'crm', label: 'CRM', navigation: app.navigation }],
70+
objects: [],
71+
}),
72+
}));
73+
74+
vi.mock('../../providers/AdapterProvider', () => ({
75+
useAdapter: () => ({ find: vi.fn(), searchAll: vi.fn() }),
76+
}));
77+
78+
vi.mock('@object-ui/auth', async (importOriginal) => ({
79+
...(await importOriginal<Record<string, unknown>>()),
80+
useAuth: () => ({ user: { id: 'u1' }, activeOrganization: null }),
81+
}));
82+
83+
import { SearchResultsPage } from '../SearchResultsPage';
84+
85+
const SPEC_NAV_TYPES = NavigationItemTypeSchema.options as readonly string[];
86+
87+
/**
88+
* One item per spec nav type, each carrying every target field any type reads,
89+
* so whether it is listed is the page's own decision, not this fixture's.
90+
*/
91+
const everyTypeNavigation = () =>
92+
SPEC_NAV_TYPES.map((type) => ({
93+
id: `nav_${type}`,
94+
type,
95+
label: `Item ${type}`,
96+
objectName: 'crm_account',
97+
dashboardName: 'crm_overview',
98+
pageName: 'crm_home',
99+
reportName: 'crm_pipeline',
100+
url: 'https://example.com/help',
101+
componentRef: 'approvals:inbox',
102+
book: 'service_manual',
103+
doc: 'getting_started',
104+
actionDef: { actionName: 'crm_refresh' },
105+
children: [],
106+
}));
107+
108+
const lookup = (pack: unknown, dotted: string): unknown =>
109+
dotted.split('.').reduce<any>((node, part) => node?.[part], pack);
110+
111+
/** The packs that carry the page's `search` block — every shipped one today. */
112+
const searchPacks = Object.entries(builtInLocales).filter(
113+
([, pack]) => typeof lookup(pack, 'search') === 'object',
114+
);
115+
116+
describe('SearchResultsPage result-type keys exist in every locale pack (objectstack#36955)', () => {
117+
asked.keys = [];
118+
app.navigation = everyTypeNavigation();
119+
render(<SearchResultsPage />);
120+
const headingKeys = [...new Set(asked.keys.filter((k) => /^search\.type\p{Lu}/u.test(k)))];
121+
const badgeKeys = [...new Set(asked.keys.filter((k) => /^search\.badge\p{Lu}/u.test(k)))];
122+
123+
it('measures something: the page lists component and doc items among its groups', () => {
124+
// Non-vacuity: the render really produced groups, including the two types
125+
// whose keys were missing.
126+
expect(searchPacks.length).toBe(Object.keys(builtInLocales).length);
127+
expect(headingKeys).toEqual(expect.arrayContaining(['search.typeComponents', 'search.typeDocs']));
128+
expect(badgeKeys).toEqual(expect.arrayContaining(['search.badgeComponent', 'search.badgeDoc']));
129+
expect(headingKeys.length).toBe(badgeKeys.length);
130+
});
131+
132+
it.each(searchPacks.map(([tag]) => tag))('%s names every heading and badge the page asks for', (tag) => {
133+
const pack = builtInLocales[tag as keyof typeof builtInLocales];
134+
const missing = [...headingKeys, ...badgeKeys].filter((key) => {
135+
const value = lookup(pack, key);
136+
return typeof value !== 'string' || value.trim() === '';
137+
});
138+
expect(missing).toEqual([]);
139+
});
140+
});

‎ui/packages/app-shell/src/views/__tests__/global-page-blocks.render.test.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ describe('objectui#6757 — spec `PageComponentType` members that had no rendere
217217

218218
// 1. Real content: the search control itself, with its accessible name.
219219
const box = screen.getByRole('searchbox', {
220-
name: 'Search objects, dashboards, pages, reports',
220+
name: 'Search objects, dashboards, pages, reports, components, docs',
221221
});
222222
expect(box).toBeInTheDocument();
223223

‎ui/packages/app-shell/src/views/global-search-renderer.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,10 @@ export const GlobalSearchRenderer: React.FC<GlobalSearchRendererProps> = ({
123123
// uses, never spliced in raw (objectui#11818).
124124
const baseUrl = `/apps/${appName || resolveHostAppSegment(apps, currentAppName)}`;
125125
const placeholder = t('search.placeholder', {
126-
defaultValue: 'Search objects, dashboards, pages, reports…',
126+
defaultValue: 'Search objects, dashboards, pages, reports, components, docs…',
127127
}) as string;
128128
const ariaLabel = t('search.inputAriaLabel', {
129-
defaultValue: 'Search objects, dashboards, pages, reports',
129+
defaultValue: 'Search objects, dashboards, pages, reports, components, docs',
130130
}) as string;
131131

132132
return (

‎ui/packages/i18n/src/locales/ar.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4222,8 +4222,8 @@ const ar = {
42224222
search: {
42234223
title: "بحث",
42244224
back: "رجوع",
4225-
placeholder: "ابحث في الكائنات، لوحات التحكم، الصفحات، التقارير…",
4226-
inputAriaLabel: "ابحث في الكائنات، لوحات التحكم، الصفحات، التقارير",
4225+
placeholder: "ابحث في الكائنات، لوحات التحكم، الصفحات، التقارير، المكونات، المستندات…",
4226+
inputAriaLabel: "ابحث في الكائنات، لوحات التحكم، الصفحات، التقارير، المكونات، المستندات",
42274227
resultsCount: "{{count}} نتيجة لـ \"{{query}}\"",
42284228
resultsCount_zero: "{{count}} نتيجة لـ \"{{query}}\"",
42294229
resultsCount_one: "{{count}} نتيجة لـ \"{{query}}\"",
@@ -4247,10 +4247,16 @@ const ar = {
42474247
typeDashboards: "لوحات التحكم",
42484248
typePages: "الصفحات",
42494249
typeReports: "التقارير",
4250+
typeComponents: "المكونات",
4251+
typeDocs: "المستندات",
4252+
typeUrls: "الروابط",
42504253
badgeObject: "كائن",
42514254
badgeDashboard: "لوحة تحكم",
42524255
badgePage: "صفحة",
42534256
badgeReport: "تقرير",
4257+
badgeComponent: "مكوّن",
4258+
badgeDoc: "مستند",
4259+
badgeUrl: "رابط",
42544260
},
42554261
empty: {
42564262
objectNotFound: "الكائن غير موجود",

‎ui/packages/i18n/src/locales/de.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3891,8 +3891,8 @@ const de = {
38913891
search: {
38923892
title: "Suche",
38933893
back: "Zurück",
3894-
placeholder: "Objekte, Dashboards, Seiten, Berichte suchen…",
3895-
inputAriaLabel: "Objekte, Dashboards, Seiten, Berichte suchen",
3894+
placeholder: "Objekte, Dashboards, Seiten, Berichte, Komponenten, Dokumente suchen…",
3895+
inputAriaLabel: "Objekte, Dashboards, Seiten, Berichte, Komponenten, Dokumente suchen",
38963896
resultsCount: "{{count}} Ergebnis für „{{query}}“",
38973897
resultsCount_one: "{{count}} Ergebnis für „{{query}}“",
38983898
resultsCount_other: "{{count}} Ergebnisse für „{{query}}“",
@@ -3905,10 +3905,16 @@ const de = {
39053905
typeDashboards: "Dashboards",
39063906
typePages: "Seiten",
39073907
typeReports: "Berichte",
3908+
typeComponents: "Komponenten",
3909+
typeDocs: "Dokumente",
3910+
typeUrls: "Links",
39083911
badgeObject: "Objekt",
39093912
badgeDashboard: "Dashboard",
39103913
badgePage: "Seite",
39113914
badgeReport: "Bericht",
3915+
badgeComponent: "Komponente",
3916+
badgeDoc: "Dokument",
3917+
badgeUrl: "Link",
39123918
},
39133919
empty: {
39143920
objectNotFound: "Objekt nicht gefunden",

‎ui/packages/i18n/src/locales/en.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4662,8 +4662,8 @@ const en = {
46624662
search: {
46634663
title: 'Search',
46644664
back: 'Back',
4665-
placeholder: 'Search objects, dashboards, pages, reports…',
4666-
inputAriaLabel: 'Search objects, dashboards, pages, reports',
4665+
placeholder: 'Search objects, dashboards, pages, reports, components, docs…',
4666+
inputAriaLabel: 'Search objects, dashboards, pages, reports, components, docs',
46674667
resultsCount: '{{count}} result for "{{query}}"',
46684668
resultsCount_one: '{{count}} result for "{{query}}"',
46694669
resultsCount_other: '{{count}} results for "{{query}}"',
@@ -4676,10 +4676,16 @@ const en = {
46764676
typeDashboards: 'Dashboards',
46774677
typePages: 'Pages',
46784678
typeReports: 'Reports',
4679+
typeComponents: 'Components',
4680+
typeDocs: 'Docs',
4681+
typeUrls: 'Links',
46794682
badgeObject: 'object',
46804683
badgeDashboard: 'dashboard',
46814684
badgePage: 'page',
46824685
badgeReport: 'report',
4686+
badgeComponent: 'component',
4687+
badgeDoc: 'doc',
4688+
badgeUrl: 'link',
46834689
},
46844690
empty: {
46854691
objectNotFound: 'Object Not Found',

‎ui/packages/i18n/src/locales/es.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3975,8 +3975,8 @@ const es = {
39753975
search: {
39763976
title: "Buscar",
39773977
back: "Atrás",
3978-
placeholder: "Buscar objetos, paneles, páginas, informes…",
3979-
inputAriaLabel: "Buscar objetos, paneles, páginas, informes",
3978+
placeholder: "Buscar objetos, paneles, páginas, informes, componentes, documentos…",
3979+
inputAriaLabel: "Buscar objetos, paneles, páginas, informes, componentes, documentos",
39803980
resultsCount: "{{count}} resultado para \"{{query}}\"",
39813981
resultsCount_one: "{{count}} resultado para \"{{query}}\"",
39823982
resultsCount_many: "{{count}} de resultados para \"{{query}}\"",
@@ -3991,10 +3991,16 @@ const es = {
39913991
typeDashboards: "Paneles",
39923992
typePages: "Páginas",
39933993
typeReports: "Informes",
3994+
typeComponents: "Componentes",
3995+
typeDocs: "Documentos",
3996+
typeUrls: "Enlaces",
39943997
badgeObject: "Objeto",
39953998
badgeDashboard: "Panel",
39963999
badgePage: "Página",
39974000
badgeReport: "Informe",
4001+
badgeComponent: "Componente",
4002+
badgeDoc: "Documento",
4003+
badgeUrl: "Enlace",
39984004
},
39994005
empty: {
40004006
objectNotFound: "Objeto no encontrado",

‎ui/packages/i18n/src/locales/fr.ts‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3971,8 +3971,8 @@ const fr = {
39713971
search: {
39723972
title: "Rechercher",
39733973
back: "Retour",
3974-
placeholder: "Rechercher des objets, tableaux de bord, pages, rapports…",
3975-
inputAriaLabel: "Rechercher des objets, tableaux de bord, pages, rapports",
3974+
placeholder: "Rechercher des objets, tableaux de bord, pages, rapports, composants, documents…",
3975+
inputAriaLabel: "Rechercher des objets, tableaux de bord, pages, rapports, composants, documents",
39763976
resultsCount: "{{count}} résultat pour \"{{query}}\"",
39773977
resultsCount_one: "{{count}} résultat pour \"{{query}}\"",
39783978
resultsCount_many: "{{count}} de résultats pour \"{{query}}\"",
@@ -3987,10 +3987,16 @@ const fr = {
39873987
typeDashboards: "Tableaux de bord",
39883988
typePages: "Pages",
39893989
typeReports: "Rapports",
3990+
typeComponents: "Composants",
3991+
typeDocs: "Documents",
3992+
typeUrls: "Liens",
39903993
badgeObject: "Objet",
39913994
badgeDashboard: "Tableau de bord",
39923995
badgePage: "Page",
39933996
badgeReport: "Rapport",
3997+
badgeComponent: "Composant",
3998+
badgeDoc: "Document",
3999+
badgeUrl: "Lien",
39944000
},
39954001
empty: {
39964002
objectNotFound: "Objet introuvable",

0 commit comments

Comments
 (0)