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
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 labelst(key, props)- For dynamic labels with propst.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
Uset.dynamic() for runtime-constructed keys:
Using in Module/Resource Definitions
Multiple Locales
Complete Example
TypeScript Types
Notes
- The
enlocale is required and serves as the fallback - All locales must have the same label keys as the
enlocale - 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
enif 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
Related
- defineModule - Use labels in module titles
- defineResource - Use labels in resource titles
- AppShell - Configure locale for the application