translate
Translates a key through the registered i18n instance. If no instance is registered, it returns the key unchanged, which keeps tests and non-i18n contexts predictable.
Importing
ts
import { translate } from '@almighty-shogun/common'Usage
ts
import { translate } from '@almighty-shogun/common'
const label = translate('navigation.dashboard');Parameters
key: string
Translation key.
params?: TranslationParams
Translation parameters.
Returns
The translated string when an i18n instance is registered. Without one, the original key is returned so callers get a predictable fallback.Type signature
ts
declare function translate(
key: string,
params?: TranslationParams
): string;