Skip to content

feat(i18n): I18nLabelSchema → string-only; remove inline i18n objects from metadata labels#1055

Merged
hotlong merged 3 commits intomainfrom
copilot/fix-i18n-label-string
Apr 2, 2026
Merged

feat(i18n): I18nLabelSchema → string-only; remove inline i18n objects from metadata labels#1055
hotlong merged 3 commits intomainfrom
copilot/fix-i18n-label-string

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 2, 2026

I18nLabelSchema was z.union([z.string(), I18nObjectSchema]), allowing label/description fields to be either a plain string or { key, defaultValue, params }. This caused React rendering crashes (objects as children), inconsistent API responses, and a parallel i18n system with hand-written keys that no translation service actually managed.

Core schema change

I18nLabelSchema is now z.string(). All UI schemas that reference it (AppSchema, NavigationArea, PageSchema, DashboardWidgetSchema, ChartSchema, NotificationSchema, AriaPropsSchema, etc.) automatically enforce string-only. I18nObjectSchema is retained for the TranslationBundle system.

-export const I18nLabelSchema = z.union([
-  z.string(),
-  I18nObjectSchema,
-]).describe('Display label: plain string or i18n translation object');
+export const I18nLabelSchema = z.string()
+  .describe('Display label (plain string; i18n keys are auto-generated by the framework)');

Plugin migrations

Converted all inline i18n objects to plain strings (extracting defaultValue):

  • plugin-setupsetup-app.ts (label, description), setup-areas.ts (4 areas × label + description)
  • plugin-auth — 5 nav item labels
  • plugin-security — 2 nav item labels
  • plugin-audit — 1 nav item label
-label: { key: 'setup.nav.users', defaultValue: 'Users' },
+label: 'Users',

Test updates

31 tests across 12 UI schema test files updated from asserting i18n objects are accepted to asserting they are rejected. All 6,792 tests pass.

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 2, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
objectstack-play Ready Ready Preview, Comment Apr 2, 2026 7:10am
spec Ready Ready Preview, Comment Apr 2, 2026 7:10am

Request Review

Copilot AI and others added 2 commits April 2, 2026 07:02
…hema simplification

I18nLabelSchema was changed from z.union([z.string(), I18nObjectSchema]) to
z.string(), so label/description/title fields now only accept plain strings.

Updated 32 tests across 12 UI schema test files to expect i18n objects to be
rejected (toThrow) instead of accepted (not.toThrow).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
…and update tests

BREAKING CHANGE: I18nLabelSchema no longer accepts i18n objects ({ key, defaultValue, params }).
All label/description/title fields in UI schemas now accept only plain strings.
i18n translation keys will be auto-generated by the framework at registration time.

Closes #1054

Agent-Logs-Url: https://github.com/objectstack-ai/framework/sessions/e1cf9252-11e8-44d6-a2d2-1f4d43c59d12

Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix i18n label to be a pure string feat(i18n): I18nLabelSchema → string-only; remove inline i18n objects from metadata labels Apr 2, 2026
Copilot AI requested a review from xuyushun441-sys April 2, 2026 07:08
@xuyushun441-sys xuyushun441-sys marked this pull request as ready for review April 2, 2026 07:12
@hotlong hotlong merged commit dc26ed8 into main Apr 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

i18n: label 应为纯字符串,key 由框架自动生成

3 participants