feat(i18n): ICU MessageFormat, placeholder, sourceHash, _meta/bidi, namespace isolation, notifications/errors, coverage breakdown, AI hooks#848
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…ceHash, _meta, namespace, notifications/errors, breakdown, AI hooks - Add `placeholder` to FieldTranslationSchema for form input hints - Add `MessageFormatSchema` (icu/simple) and `messageFormat` to TranslationConfigSchema - Add `_meta` (locale, direction/bidi) to AppTranslationBundleSchema for RTL support - Add `namespace` to AppTranslationBundleSchema for plugin isolation - Add `_notifications` and `_errors` to ObjectTranslationNodeSchema and AppTranslationBundleSchema - Add `sourceHash` to TranslationDiffItemSchema for precise stale detection - Add `aiSuggested` and `aiConfidence` to TranslationDiffItemSchema - Add `CoverageBreakdownEntrySchema` and `breakdown` to TranslationCoverageResultSchema - Add `suggestTranslations` optional method to II18nService contract - Add 21 new tests covering all new fields and schemas - Update ROADMAP.md with enhanced i18n capabilities Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
…cription Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
@copilot 评估是否完成了任务中的所有开发要求,并 fix test |
All 8 issue requirements are fully implemented and tested. Tests: 229 files, 6613 tests all passing. Build succeeds cleanly. Completeness summary:
The CI status shows "action_required" (waiting for workflow approval to run), not a test failure. ROADMAP.md is also updated (commit |
There was a problem hiding this comment.
Pull request overview
Updates the i18n protocol in @objectstack/spec to support richer translation workflows (ICU MessageFormat, placeholders, namespacing, notifications/errors grouping, coverage breakdown, and AI suggestion hooks) while keeping additions optional and backward compatible.
Changes:
- Extend translation schemas with
placeholder, ICU/simplemessageFormat, bundle_meta(locale/direction),namespace, notifications/errors groups, diffsourceHash, AI suggestion fields, and coveragebreakdown. - Add
II18nService.suggestTranslations?contract hook for AI/TMS-powered suggestions. - Add/extend tests and update ROADMAP to reflect the enhanced i18n protocol.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/spec/src/system/translation.zod.ts | Adds optional schema fields for ICU support, bundle metadata, namespace isolation, notifications/errors groups, diff hashing + AI suggestion metadata, and coverage breakdown. |
| packages/spec/src/system/translation.test.ts | Adds coverage for the new schema fields and defaults (placeholder, messageFormat, _meta, namespace, notifications/errors, diff/sourceHash, AI fields, breakdown). |
| packages/spec/src/contracts/i18n-service.ts | Extends the i18n service contract with optional suggestTranslations async hook. |
| packages/spec/src/contracts/i18n-service.test.ts | Validates backward compatibility and type compatibility for implementations including suggestTranslations. |
| ROADMAP.md | Documents the i18n protocol enhancements and the new service hook. |
| */ | ||
| _meta: z.object({ | ||
| /** BCP-47 locale code this bundle represents */ | ||
| locale: z.string().optional().describe('BCP-47 locale code for this bundle'), |
There was a problem hiding this comment.
In _meta, consider reusing the existing LocaleSchema for locale instead of z.string(). This keeps locale fields consistent across the i18n spec and makes it easier to tighten locale validation later in one place.
| locale: z.string().optional().describe('BCP-47 locale code for this bundle'), | |
| locale: LocaleSchema.optional().describe('BCP-47 locale code for this bundle'), |
| /** Notification message translations keyed by notification name */ | ||
| _notifications: z.record(z.string(), z.object({ | ||
| title: z.string().optional().describe('Translated notification title'), | ||
| body: z.string().optional().describe('Translated notification body (supports ICU MessageFormat when enabled)'), | ||
| })).optional().describe('Notification translations keyed by notification name'), |
There was a problem hiding this comment.
_notifications and bundle-level notifications both define the same { title?, body? } value shape inline. Consider extracting a shared NotificationTranslationSchema (similar to OptionTranslationMapSchema) to avoid duplication and keep future changes in sync.
| /** Global notification translations not bound to a specific object */ | ||
| notifications: z.record(z.string(), z.object({ | ||
| title: z.string().optional().describe('Translated notification title'), | ||
| body: z.string().optional().describe('Translated notification body (supports ICU MessageFormat when enabled)'), | ||
| })).optional().describe('Global notification translations keyed by notification name'), |
There was a problem hiding this comment.
notifications uses the same { title?, body? } schema as ObjectTranslationNodeSchema._notifications. Consider referencing a shared schema constant to avoid having two copies of the same structure to maintain.
Enhances the i18n protocol to align with Salesforce/Dynamics/ICU standards. All additions are optional fields — fully backward compatible.
Schema additions
FieldTranslationSchema—placeholderfor form input hintsTranslationConfigSchema—messageFormat('icu' | 'simple') via newMessageFormatSchemaenum, defaulting to'simple'AppTranslationBundleSchema:_meta: { locale, direction }— RTL/bidi rendering hints (Arabic, Hebrew)namespace— plugin/extension translation key isolationnotifications,errors— global notification/error message groupsObjectTranslationNodeSchema—_notifications,_errors(follows existing_views/_actionsunderscore convention)TranslationDiffItemSchema—sourceHashfor incremental stale detection;aiSuggested+aiConfidencefor TMS/agent integrationTranslationCoverageResultSchema—breakdownarray ofCoverageBreakdownEntrySchemafor per-group (fields/views/actions/messages) coverage statsContract addition
II18nService.suggestTranslations?— async hook returning diff items enriched with AI suggestions21 new tests, 6613 total passing.
Original prompt
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.