Skip to content

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/vue-utils'

Usage

ts
import { translate } from '@almighty-shogun/vue-utils'

const label = translate('navigation.dashboard');

Parameters

NameTypeDescription
keystringTranslation key.
paramsTranslationParamsOptional 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;

All packages are released under the MIT License.