Skip to content

translationExists

Checks whether a translation key exists through the active i18n instance, preferring its te method and falling back to $te. When subKeys are provided, every nested key must exist for the function to return true.

The instance is resolved the same way as in translate: a registered instance first, then $i18n on the current component instance. If neither resolves, or the resolved instance exposes neither method, the helper always returns false.

Importing

ts
import { translationExists } from '@almighty-shogun/common';

Usage

ts
import { translationExists } from '@almighty-shogun/common';

const hasMenuTranslations = translationExists('nav', ['dashboard', '..']);

Parameters

key: string
Base translation key.

subKeys?: string[]
Subkeys that must all exist under the base key.
Default: []

Returns

true when the registered i18n instance reports that the key exists. When subKeys are provided, all nested keys must exist.

Type signature

ts
declare function translationExists(
    key: string,
    subKeys?: string[]
): boolean;

All packages are released under the MIT License.