From 2af97f1f57c5764e4a5cf9c7c5e7f66a5fb86971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=9A=A9=EA=B1=B4=20=28Kim=20Younggeon=29?= Date: Mon, 20 Jan 2025 20:00:30 +0900 Subject: [PATCH] fix: `$has` always returns `true` --- src/runtime/plugins/01.plugin.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/runtime/plugins/01.plugin.ts b/src/runtime/plugins/01.plugin.ts index 5c2577bb..aa0feaf5 100644 --- a/src/runtime/plugins/01.plugin.ts +++ b/src/runtime/plugins/01.plugin.ts @@ -146,7 +146,7 @@ export default defineNuxtPlugin(async (nuxtApp) => { const selectedRoute = route ?? routeService.getCurrentRoute() return routeService.getRouteName(selectedRoute, selectedLocale) }, - t: (key: string, params?: Params, defaultValue?: string): Translation => { + t: (key: string, params?: Params, defaultValue?: string | null): Translation => { if (!key) return '' const route = routeService.getCurrentRoute() const locale = routeService.getCurrentLocale() @@ -157,7 +157,7 @@ export default defineNuxtPlugin(async (nuxtApp) => { if (isDev && import.meta.client) { console.warn(`Not found '${key}' key in '${locale}' locale messages.`) } - value = defaultValue || key + value = defaultValue === undefined ? key : defaultValue } return typeof value === 'string' && params ? interpolate(value, params) : value @@ -185,7 +185,7 @@ export default defineNuxtPlugin(async (nuxtApp) => { return translationService.formatRelativeTime(value, currentLocale, options) }, has: (key: string): boolean => { - return !!provideData.t(key) + return !!provideData.t(key, {}, null) }, mergeTranslations: (newTranslations: Translations) => { const route = routeService.getCurrentRoute()