Repository navigation
Commit bb5d4ee
fix: plugin-ai i18n wiring and Studio times in the display locale (objectui#10232) (#10328)
Fixes #10232
Clause-②: no
Both display-locale faces on objectui#10232, in one PR. Implemented by
`session_01D486C1axmXnrkJMNUfz2eb` (seat `domain:ui#3`), based on
`8b1f06619`.
## What changed
### Item 2: Studio faces no longer use `useMetadataLocale()` as an
`Intl` locale
- `StudioHomePage`: the "recently viewed" `relativeTime` now gets
`useDisplayLocale()`. It used to get `useMetadataLocale()`.
- `StudioDesignSurface` (`DataPillar`): the last-saved time
(`savedAt.toLocaleTimeString`) also uses `useDisplayLocale()`. The
sentence around it still comes from the designer's string table.
- `metadata-admin/i18n.ts`: the `useMetadataLocale` docblock now says it
must never be used as an `Intl` locale, because it is `'en-US'` for
every language except zh. It is kept for the two-language `t()` /
`tFormat()` tables.
- Premise re-derived on `8b1f06619`. The hook is still
`/^zh/i.test(language) ? 'zh-CN' : 'en-US'`. I checked every file that
calls `useMetadataLocale()` for `Intl.*` / `toLocale*` / `*Format(…
locale …)` uses, and these two faces are the only ones. The other `Intl`
sites in those files (`ResourceHistoryPage`, `JobPreview`,
`ExternalDatasourcePanel`, `DatasetPreview`) already use the display
locale since objectui#9909.
### Item 1: `@object-ui/plugin-ai` wired to `@object-ui/i18n` as a whole
- `packages/plugin-ai/package.json` adds `@object-ui/i18n` (dependency)
and `@object-ui/test-support` (devDependency). `pnpm-lock.yaml` was
regenerated by `pnpm install` (6 added lines in the plugin-ai importer),
not edited by hand.
- New `src/useAiTranslation.ts` follows the plugin-chatbot
`useAiApprovalsTranslation.ts` shape. It holds a `createSafeTranslation`
defaults map that mirrors the `en` pack, plus `formatPercent(score,
locale)`.
- Strings: 17 keys in a new `ai.*` namespace (`ai.nlQuery.*` 7,
`ai.formAssist.*` 7, `ai.recommendations.*` 3), translated in all ten
packs. Counts use the repo's two-key plural convention (`*One` is picked
at the call site when the count is exactly one, as with
`search.itemsAvailableOne`).
- Display locale: the `nl-query` history date is now
`toLocaleDateString(displayLocale)`. It was a bare
`toLocaleDateString()`, which uses the machine's locale. The confidence
and score percentages go through `Intl.NumberFormat(displayLocale,
percent)` instead of a `Math.round(...)` followed by a literal percent
sign.
- README: new "Localization" section.
`content/docs/plugins/plugin-ai.mdx` points readers to the README.
### Census coverage (hypothesis 4)
The objectui#9909 census is
`packages/i18n/src/__tests__/machineLocaleCensus-9909.test.ts`. It
builds its population from every workspace manifest that names
`@object-ui/i18n`, so after this change it covers `packages/plugin-ai`
with no edit to the census file. With the fix, the history-date
expression passes the census. With the ablation below (the bare call put
back), the census goes red on its `no call site passes nothing,
undefined or the default pseudo-tag unless it is declared` case.
### One PR, not two
Triage allowed a split. I kept one PR because both items are small,
their file sets don't overlap, and the claim names this one branch. A
second PR would need a second branch that no claim names, plus a second
write.
## Tests (source tree at `5bab5d4d7`; `e957b05fc` adds only the README
section)
- New `packages/plugin-ai/src/aiComponents.i18n-10232.test.tsx`: history
date de-DE `4.3.2020` vs en `3/4/2020`; the two sessions differ; runtime
tripwire; de strings; the singular key at one; de-DE percent; English
with no provider; the defaults map mirrors the `en` pack in both
directions.
- New
`packages/app-shell/src/views/metadata-admin/StudioHomePage.displayLocale-10232.test.tsx`:
`vor 3 Tagen` vs `3 days ago` with the UI language `en` in both
sessions, plus the tripwire.
- New
`packages/app-shell/src/views/studio-design/DataPillar.savedAtDisplayLocale-10232.test.tsx`:
a real auto-save lands, de-DE shows a 24-hour time, en shows AM/PM, plus
the tripwire.
- `vitest run packages/plugin-ai/ packages/i18n/src/__tests__/`: 73
files, 1182 tests passed (includes the census and all-locales key
parity).
- `vitest run` DataPillar* + studio-locale + metadataAdminFaces-9909 +
StudioHomePage-10232 + the two AppContent route suites: 12 files, 97
tests passed. `StudioDesignSurface*`: 23 files, 118 tests passed.
- `pnpm --filter @object-ui/plugin-ai run type-check` and `build` exit
0. `pnpm --filter @object-ui/app-shell run type-check` exits 0 after
building its dependency closure.
- Ablation (committed first, trap restore, then `git diff HEAD` checked
empty): three edits confirmed on disk by `grep -c` (mutant 1 1 1, fix 0
0 0). Result: 9 failed, 15 passed across the 4 files, including the
census case above. Tree restored.
## Gates (exit codes captured to files before reading)
`check:i18n-keys` 0 · `check:i18n-drift` 0 (17 keys added, 0 en values
changed) · `check:i18n-dead-keys` 0 (no `ai.*` key listed) ·
`check:i18n-designer-parity` 0 · `check:phantom-deps` 0 ·
`check:unused-deps` 0 · `check:control-bytes` 0 ·
`check:new-line-citations` 0 · `check:published-tsconfig-exclude` 0 ·
`check:lockfile-integrity` 0 · `check:lockfile-dedupe` 0 ·
`check:vi-mock-*` 0 · `check:test-path-roots` 0 ·
`check:changeset-claims` 0 · `check:pending-changeset-literals` 0 ·
`check:esm-specifiers` 0 · `check:governed-queue-guard` 0 ·
`check:unreferenced-sources` 0 · `check:self-import` 0 · changeset
presence 0 · no-major 0 · eslint on the 20 touched ts/tsx files: 0
errors (20 warnings, all on lines this PR does not touch).
- NOT MEASURED: `check:eager-locale-catalogues`, reason: PREREQUISITE
NOT MET (needs a built `apps/console/dist`). `check:dist-completeness`,
reason: `packages/app-shell/dist` was not built locally (only its
dependency closure was). Full app-shell and console suites and a
repo-wide lint are left to CI.
## Acceptance notes
- The plugin-ai icon-only buttons (refresh, dismiss, apply, reject) have
no accessible names. That is outside this card, and no carrier was
identified.
- The `ComponentRegistry` labels in `plugin-ai/src/index.tsx` are
English designer metadata, like every other plugin's registration
labels. They are not translated here.
- `ai-recommendations` offers `layout: 'carousel'` (in the schema type
and the registration enum), but the renderer shows it as a list.
Reported to the seat, not changed here.
- Draft PR objectui#8941 also edits `packages/plugin-ai/package.json`
and `pnpm-lock.yaml`. Whichever lands second regenerates the lockfile.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01D486C1axmXnrkJMNUfz2eb)_
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Leehom <pm@objectstack.ai>1 parent b57107d commit bb5d4ee
24 files changed
Lines changed: 785 additions & 20 deletions
File tree
- .changeset
- packages
- app-shell/src/views
- metadata-admin
- studio-design
- i18n/src/locales
- plugin-ai
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
Lines changed: 104 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| 47 | + | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| |||
118 | 119 | | |
119 | 120 | | |
120 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
121 | 127 | | |
122 | 128 | | |
123 | 129 | | |
| |||
141 | 147 | | |
142 | 148 | | |
143 | 149 | | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
144 | 153 | | |
145 | 154 | | |
146 | 155 | | |
| |||
421 | 430 | | |
422 | 431 | | |
423 | 432 | | |
424 | | - | |
| 433 | + | |
425 | 434 | | |
426 | 435 | | |
427 | 436 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4756 | 4756 | | |
4757 | 4757 | | |
4758 | 4758 | | |
| 4759 | + | |
| 4760 | + | |
| 4761 | + | |
| 4762 | + | |
| 4763 | + | |
| 4764 | + | |
| 4765 | + | |
| 4766 | + | |
4759 | 4767 | | |
4760 | 4768 | | |
4761 | 4769 | | |
| |||
Lines changed: 109 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| |||
2656 | 2657 | | |
2657 | 2658 | | |
2658 | 2659 | | |
| 2660 | + | |
| 2661 | + | |
| 2662 | + | |
| 2663 | + | |
2659 | 2664 | | |
2660 | 2665 | | |
2661 | 2666 | | |
| |||
3173 | 3178 | | |
3174 | 3179 | | |
3175 | 3180 | | |
3176 | | - | |
| 3181 | + | |
3177 | 3182 | | |
3178 | 3183 | | |
3179 | 3184 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2927 | 2927 | | |
2928 | 2928 | | |
2929 | 2929 | | |
| 2930 | + | |
| 2931 | + | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + | |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
| 2943 | + | |
| 2944 | + | |
| 2945 | + | |
| 2946 | + | |
| 2947 | + | |
| 2948 | + | |
| 2949 | + | |
| 2950 | + | |
| 2951 | + | |
| 2952 | + | |
| 2953 | + | |
| 2954 | + | |
2930 | 2955 | | |
2931 | 2956 | | |
2932 | 2957 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2915 | 2915 | | |
2916 | 2916 | | |
2917 | 2917 | | |
| 2918 | + | |
| 2919 | + | |
| 2920 | + | |
| 2921 | + | |
| 2922 | + | |
| 2923 | + | |
| 2924 | + | |
| 2925 | + | |
| 2926 | + | |
| 2927 | + | |
| 2928 | + | |
| 2929 | + | |
| 2930 | + | |
| 2931 | + | |
| 2932 | + | |
| 2933 | + | |
| 2934 | + | |
| 2935 | + | |
| 2936 | + | |
| 2937 | + | |
| 2938 | + | |
| 2939 | + | |
| 2940 | + | |
| 2941 | + | |
| 2942 | + | |
2918 | 2943 | | |
2919 | 2944 | | |
2920 | 2945 | | |
| |||
0 commit comments