Skip to content

@salesforce/b2c-tooling-sdk / i18n / t

Function: t()

t(key, defaultValue, options?): string

Defined in: packages/b2c-tooling-sdk/src/i18n/index.ts:187

Translate a message key with an inline default.

The default string is used directly during development and serves as the English translation. Future localization adds translations via locale files without changing call sites.

Parameters

key

string

Dot-notation key (e.g., 'error.serverRequired')

defaultValue

string

The default English string

options?

TOptions

Optional interpolation values

Returns

string

The translated string

Examples

ts
// Simple usage
t('error.serverRequired', 'Server is required.')
ts
// With interpolation
t('error.fileNotFound', 'File {{path}} not found.', { path: filePath })
ts
// With multiple interpolations
t('info.uploadProgress', 'Uploading {{file}} ({{percent}}%)', { file: name, percent: 50 })

All rights reserved.