Keyboard shortcuts

Press or to navigate between chapters

Press ? to show this help

Press Esc to hide this help

Internationalization Nodes

Voce IR supports two i18n compilation modes. In static mode (default), the compiler resolves all LocalizedStrings against the target locale’s MessageCatalog and emits fully resolved HTML per locale with zero runtime i18n code. In runtime mode, a single output is emitted with locale switching and on-demand translation loading (~1KB runtime).

LocalizedString

A reference to a translated message, used in TextNode content, FormField labels, PageMetadata, and anywhere user-visible text appears. The validator checks that every message_key exists in all declared locale catalogs.

FieldTypeRequiredDescription
message_keystringyesMessage key (e.g., “hero.title”, “form.email.label”)
default_valuestringnoFallback value in the primary language
parameters[MessageParameter]noTyped parameters for interpolation
descriptionstringnoContext for translators

MessageParameter

FieldTypeRequiredDescription
namestringyesParameter name (e.g., “count”, “name”)
param_typeMessageParamTypenoStringParam (default), NumberParam, DateParam, CurrencyParam, PluralParam, SelectParam
format_optionsFormatOptionsnoFormatting configuration
{
  "message_key": "cart.item_count",
  "default_value": "{count, plural, one {# item} other {# items}} in your cart",
  "parameters": [
    { "name": "count", "param_type": "PluralParam" }
  ],
  "description": "Shopping cart item count displayed in the header"
}

MessageCatalog

A collection of translated messages for a single locale. Stored as a companion file alongside the IR, not embedded in the main binary.

FieldTypeRequiredDescription
localestringyesBCP 47 locale tag (e.g., “en-US”, “fr-FR”)
messages[Message]yesAll translated messages for this locale
fallback_localestringnoFallback locale (e.g., “en” for “en-US”)

Message

FieldTypeRequiredDescription
keystringyesMessage key matching LocalizedString.message_key
valuestringyesICU MessageFormat translated string

ICU MessageFormat supports plurals, select, and nested expressions:

  • Simple: "Hello {name}"
  • Plural: "{count, plural, one {# item} other {# items}}"
  • Select: "{gender, select, female {She} male {He} other {They}} commented"
{
  "locale": "fr-FR",
  "messages": [
    { "key": "hero.title", "value": "Bienvenue sur Voce" },
    { "key": "hero.subtitle", "value": "Representation intermediaire pour l'IA" },
    { "key": "cart.item_count", "value": "{count, plural, one {# article} other {# articles}} dans votre panier" }
  ],
  "fallback_locale": "en"
}

FormatOptions

Locale-aware formatting configuration for number, date, and currency parameters.

FieldTypeRequiredDescription
number_styleNumberStylenoDecimal (default), Currency, Percent, Unit
currency_codestringnoISO 4217 code (e.g., “USD”, “EUR”) for Currency style
date_styleDateStylenoShort, Medium (default), Long, Full, Custom
custom_date_patternstringnoICU date pattern for Custom style (e.g., “yyyy-MM-dd”)
min_fraction_digitsint32noMinimum fractional digits for numbers
max_fraction_digitsint32noMaximum fractional digits for numbers
{
  "number_style": "Currency",
  "currency_code": "EUR",
  "min_fraction_digits": 2,
  "max_fraction_digits": 2
}

I18nConfig

Application-level internationalization configuration. Added to VoceDocument.i18n.

FieldTypeRequiredDescription
default_localestringyesDefault/primary locale (e.g., “en-US”)
supported_locales[string]yesAll supported locale tags
modestringno“static” (default) or “runtime”

Compilation modes:

  • static – one output per locale. All LocalizedStrings resolved at compile time. Zero runtime cost. Best for SEO and performance.
  • runtime – single output with locale switching. Translations loaded on demand. Adds ~1KB of i18n runtime. Best for SPAs with in-app language switching.
{
  "default_locale": "en-US",
  "supported_locales": ["en-US", "fr-FR", "de-DE", "ja-JP"],
  "mode": "static"
}