I18n
I18n protocol schemas
I18n Object Schema
Structured internationalization label with translation key and parameters.
@example
const label: I18nObject = \{
key: 'views.task_list.label',
defaultValue: 'Task List',
params: \{ count: 5 \},
\};Source: packages/spec/src/ui/i18n.zod.ts
TypeScript Usage
import { AriaProps, DateFormat, I18nLabel, I18nObject, LocaleConfig, NumberFormat, PluralRule } from '@objectstack/spec/ui';
import type { AriaProps, DateFormat, I18nLabel, I18nObject, LocaleConfig, NumberFormat, PluralRule } from '@objectstack/spec/ui';
// Validate data
const result = AriaProps.parse(data);AriaProps
ARIA accessibility attributes
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| ariaLabel | string | Object | optional | Accessible label for screen readers (WAI-ARIA aria-label) |
| ariaDescribedBy | string | optional | ID of element providing additional description (WAI-ARIA aria-describedby) |
| role | string | optional | WAI-ARIA role attribute (e.g., "dialog", "navigation", "alert") |
DateFormat
Date/time formatting rules
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| dateStyle | Enum<'full' | 'long' | 'medium' | 'short'> | optional | Date display style |
| timeStyle | Enum<'full' | 'long' | 'medium' | 'short'> | optional | Time display style |
| timeZone | string | optional | IANA time zone (e.g., "America/New_York") |
| hour12 | boolean | optional | Use 12-hour format |
I18nLabel
Display label: plain string or i18n translation object
Union Options
This schema accepts one of the following structures:
Option 1
Type: string
Option 2
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| key | string | ✅ | Translation key (e.g., "views.task_list.label") |
| defaultValue | string | optional | Fallback value when translation key is not found |
| params | Record<string, string | number | boolean> | optional | Interpolation parameters (e.g., { count: 5 }) |
I18nObject
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| key | string | ✅ | Translation key (e.g., "views.task_list.label") |
| defaultValue | string | optional | Fallback value when translation key is not found |
| params | Record<string, string | number | boolean> | optional | Interpolation parameters (e.g., { count: 5 }) |
LocaleConfig
Locale configuration
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| code | string | ✅ | BCP 47 language code (e.g., "en-US", "zh-CN") |
| fallbackChain | string[] | optional | Fallback language codes in priority order (e.g., ["zh-TW", "en"]) |
| direction | Enum<'ltr' | 'rtl'> | ✅ | Text direction: left-to-right or right-to-left |
| numberFormat | Object | optional | Default number formatting rules |
| dateFormat | Object | optional | Default date/time formatting rules |
NumberFormat
Number formatting rules
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| style | Enum<'decimal' | 'currency' | 'percent' | 'unit'> | ✅ | Number formatting style |
| currency | string | optional | ISO 4217 currency code (e.g., "USD", "EUR") |
| unit | string | optional | Unit for unit formatting (e.g., "kilometer", "liter") |
| minimumFractionDigits | number | optional | Minimum number of fraction digits |
| maximumFractionDigits | number | optional | Maximum number of fraction digits |
| useGrouping | boolean | optional | Whether to use grouping separators (e.g., 1,000) |
PluralRule
ICU plural rules for a translation key
Properties
| Property | Type | Required | Description |
|---|---|---|---|
| key | string | ✅ | Translation key |
| zero | string | optional | Zero form (e.g., "No items") |
| one | string | optional | Singular form (e.g., "{count} item") |
| two | string | optional | Dual form (e.g., "{count} items" for exactly 2) |
| few | string | optional | Few form (e.g., for 2-4 in some languages) |
| many | string | optional | Many form (e.g., for 5+ in some languages) |
| other | string | ✅ | Default plural form (e.g., "{count} items") |