Skip to content

@serenity-is/corelib / LT / getDefault

Variable: getDefault()

const getDefault: (key, defaultText?) => string = localText

Defined in: src/base/localtext.ts:217

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

Use localText directly.