Skip to content

translationExists

Checks whether a translation key exists through the registered i18n instance. When subKeys are provided, every nested key must exist for the function to return true.

Importing

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

Usage

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

const hasMenuTranslations = translationExists('navigation', ['dashboard', 'settings']);

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.