Skip to main content
Defines internationalization labels for multiple locales. The en locale is required as the default locale. Labels can be either static strings or dynamic functions that take props.

Signature

Parameters

I18nLabels
required
Object with locale keys containing label definitions. The en locale is required.Each locale object contains:
  • Static string labels: key: "Label text"
  • Dynamic function labels: key: (props: T) => string
All locales must have the same label keys as the en locale. For dynamic labels (functions), the props type must match across all locales.

Return Type

() => TFunction
React hook that returns a translator function for use in components.The translator function has two forms:
  • t(key) - For static labels
  • t(key, props) - For dynamic labels with props
  • t.dynamic(key, fallback) - For runtime-constructed keys with fallback
<K extends keyof Def>(key: K, ...args: TFunctionArgs<K>) => LocalizedString
Function to get a LocalizedString for use in module/resource meta.title.Note: When using dynamic labels with props in meta.title, the props are bound at definition time (when calling labels.t), not at render time.

Examples

Basic Labels Definition

Dynamic Labels with Props

Using in Components

Dynamic Label Resolution

Use t.dynamic() for runtime-constructed keys:

Using in Module/Resource Definitions

Multiple Locales

Complete Example

TypeScript Types

Notes

  • The en locale is required and serves as the fallback
  • All locales must have the same label keys as the en locale
  • For dynamic labels (functions), the props type must match across all locales
  • The browser’s language preference is automatically detected to select the appropriate locale
  • Falls back to en if the detected locale is not defined
  • When using dynamic labels with props in meta.title, the props are bound at definition time, not at render time