Skip to main content
penscript supports locale-aware content through the :i18n operator. This allows forms, notifications, case labels, and any text content to be served in the right language automatically — based on the contact’s or user’s locale.

Inline Translations: :i18n

Returns a localized string based on the active locale. The scope must include a locales array that defines the user’s preferred languages, ordered by preference.
{
  ":i18n": {
    "fr": "Bonjour {user.given_name}",
    "en": "Hello {user.given_name}"
  }
}

// Scope (FR): { "locales": ["fr", "en"], "user": { "given_name": "Marie" } }
// Result: "Bonjour Marie"

// Scope (EN): { "locales": ["en", "fr"], "user": { "given_name": "Alex" } }
// Result: "Hello Alex"
The operator checks the locales array in order and returns the first matching translation. If the preferred locale isn’t available, it falls back to the next one in the list.

Variable Interpolation

Translations support full variable interpolation — any penscript variable can be used inside the translated strings:
{
  ":i18n": {
    "fr": "Votre dossier #{case.reference} a été créé le {case.created_at | formatDdMmYyyy}.",
    "nl": "Uw dossier #{case.reference} werd aangemaakt op {case.created_at | formatDdMmYyyy}.",
    "en": "Your case #{case.reference} was created on {case.created_at | formatDdMmYyyy}."
  }
}
Variables are resolved after the locale is selected, so each translation can reference any value available in the scope.

Where to Use :i18n

The :i18n operator works anywhere penscript is evaluated:
  • Form labels and descriptions — display element titles in the contact’s language
  • Notification content — emails and SMS in the right language
  • Welcome and completion pages — localized form instructions
  • Case status labels — localized status names for display
  • Document generation — language-specific content in generated documents
For forms, the contact’s language preference determines which translation is shown. For internal-facing content, the workspace member’s language is used.

Next Steps