Translation
Translation protocol schemas
Field Translation Schema
Translation data for a single field.
Source: packages/spec/src/system/translation.zod.ts
TypeScript Usage
import { FieldTranslation, Locale, ObjectTranslationData, TranslationBundle, TranslationConfig, TranslationData, TranslationFileOrganization } from '@objectstack/spec/system';
import type { FieldTranslation, Locale, ObjectTranslationData, TranslationBundle, TranslationConfig, TranslationData, TranslationFileOrganization } from '@objectstack/spec/system';
// Validate data
const result = FieldTranslation.parse(data);FieldTranslation
Translation data for a single field
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| label | string | optional | Translated field label |
| help | string | optional | Translated help text |
| options | Record<string, string> | optional | Option value to translated label map |
ObjectTranslationData
Translation data for a single object
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| label | string | ✅ | Translated singular label |
| pluralLabel | string | optional | Translated plural label |
| fields | Record<string, Object> | optional | Field-level translations |
TranslationConfig
Internationalization configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| defaultLocale | string | ✅ | Default locale (e.g., "en") |
| supportedLocales | string[] | ✅ | Supported BCP-47 locale codes |
| fallbackLocale | string | optional | Fallback locale code |
| fileOrganization | Enum<'bundled' | 'per_locale' | 'per_namespace'> | ✅ | File organization strategy |
| lazyLoad | boolean | ✅ | Load translations on demand |
| cache | boolean | ✅ | Cache loaded translations |
TranslationData
Translation data for objects, apps, and UI messages
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| objects | Record<string, Object> | optional | Object translations keyed by object name |
| apps | Record<string, Object> | optional | App translations keyed by app name |
| messages | Record<string, string> | optional | UI message translations keyed by message ID |
| validationMessages | Record<string, string> | optional | Translatable validation error messages keyed by rule name (e.g., {"discount_limit": "折扣不能超过40%"}) |
TranslationFileOrganization
Translation file organization strategy
Allowed Values
bundledper_localeper_namespace