ObjectStackObjectStack

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

PropertyTypeRequiredDescription
ariaLabelstring | ObjectoptionalAccessible label for screen readers (WAI-ARIA aria-label)
ariaDescribedBystringoptionalID of element providing additional description (WAI-ARIA aria-describedby)
rolestringoptionalWAI-ARIA role attribute (e.g., "dialog", "navigation", "alert")

DateFormat

Date/time formatting rules

Properties

PropertyTypeRequiredDescription
dateStyleEnum<'full' | 'long' | 'medium' | 'short'>optionalDate display style
timeStyleEnum<'full' | 'long' | 'medium' | 'short'>optionalTime display style
timeZonestringoptionalIANA time zone (e.g., "America/New_York")
hour12booleanoptionalUse 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

PropertyTypeRequiredDescription
keystringTranslation key (e.g., "views.task_list.label")
defaultValuestringoptionalFallback value when translation key is not found
paramsRecord<string, string | number | boolean>optionalInterpolation parameters (e.g., { count: 5 })


I18nObject

Properties

PropertyTypeRequiredDescription
keystringTranslation key (e.g., "views.task_list.label")
defaultValuestringoptionalFallback value when translation key is not found
paramsRecord<string, string | number | boolean>optionalInterpolation parameters (e.g., { count: 5 })

LocaleConfig

Locale configuration

Properties

PropertyTypeRequiredDescription
codestringBCP 47 language code (e.g., "en-US", "zh-CN")
fallbackChainstring[]optionalFallback language codes in priority order (e.g., ["zh-TW", "en"])
directionEnum<'ltr' | 'rtl'>Text direction: left-to-right or right-to-left
numberFormatObjectoptionalDefault number formatting rules
dateFormatObjectoptionalDefault date/time formatting rules

NumberFormat

Number formatting rules

Properties

PropertyTypeRequiredDescription
styleEnum<'decimal' | 'currency' | 'percent' | 'unit'>Number formatting style
currencystringoptionalISO 4217 currency code (e.g., "USD", "EUR")
unitstringoptionalUnit for unit formatting (e.g., "kilometer", "liter")
minimumFractionDigitsnumberoptionalMinimum number of fraction digits
maximumFractionDigitsnumberoptionalMaximum number of fraction digits
useGroupingbooleanoptionalWhether to use grouping separators (e.g., 1,000)

PluralRule

ICU plural rules for a translation key

Properties

PropertyTypeRequiredDescription
keystringTranslation key
zerostringoptionalZero form (e.g., "No items")
onestringoptionalSingular form (e.g., "{count} item")
twostringoptionalDual form (e.g., "{count} items" for exactly 2)
fewstringoptionalFew form (e.g., for 2-4 in some languages)
manystringoptionalMany form (e.g., for 5+ in some languages)
otherstringDefault plural form (e.g., "{count} items")

On this page