@serenity-is/corelib / text
Variable: text()
consttext: (key,defaultText?) =>string=localText
Defined in: src/base/localtext.ts:201
Alias for localText.
Retrieves a localized string for a key, falling back gracefully.
Parameters
key
string
Localization key to look up (e.g. "Dialogs.YesButton"). If falsy, an empty string or defaultText is returned.
defaultText?
string
Optional fallback returned when the key is not found. When omitted, the key itself is returned.
Returns
string
The localized value, defaultText if provided, the key itself, or "" for nullish keys.
Example
localText("Dialogs.YesButton"); // "Yes" if registered, otherwise "Dialogs.YesButton"
localText("Missing.Key", "Fallback"); // "Fallback"
Deprecated
Prefer localText directly for better discoverability and consistency.