From 0202ff60a8c52d848a17d27c4ec3780b60d0386b Mon Sep 17 00:00:00 2001 From: Pavel Kuzmin Date: Sat, 17 Aug 2024 15:55:15 +0500 Subject: [PATCH] add: key check --- src/runtime/01.plugin.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/runtime/01.plugin.ts b/src/runtime/01.plugin.ts index b553916b..588aef94 100644 --- a/src/runtime/01.plugin.ts +++ b/src/runtime/01.plugin.ts @@ -191,6 +191,10 @@ export default defineNuxtPlugin(async (_nuxtApp) => { params?: T, defaultValue?: string, ): string | number | boolean | Translations | PluralTranslations | unknown[] | unknown | null => { + if (!key) { + console.log(`$t: key not exist`) + return '' + } const locale = (route.params?.locale ?? i18nConfig.defaultLocale).toString() const routeName = (route.name as string).replace(`localized-`, '') @@ -211,6 +215,10 @@ export default defineNuxtPlugin(async (_nuxtApp) => { return value }, tc: (key: string, count: number, defaultValue?: string): string => { + if (!key) { + console.log(`$tc: key not exist`) + return '' + } const locale = (route.params?.locale ?? i18nConfig.defaultLocale).toString() const routeName = (route.name as string).replace(`localized-`, '')