Skip to content

Commit

Permalink
add: key check
Browse files Browse the repository at this point in the history
  • Loading branch information
s00d committed Aug 17, 2024
1 parent f005fd8 commit 0202ff6
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/runtime/01.plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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-`, '')

Expand All @@ -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-`, '')

Expand Down

0 comments on commit 0202ff6

Please sign in to comment.