Skip to content

Commit

Permalink
fix: gracefully handle unknown locales
Browse files Browse the repository at this point in the history
  • Loading branch information
brc-dd committed Mar 4, 2024
1 parent 2f60737 commit fcac3bc
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/runtime/composables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,6 @@ export function useLocale<T>(
locale: computed(() => locale.value),
setLocale,
localizePath,
t: t!
t: t || {} as any
}
}
2 changes: 1 addition & 1 deletion src/runtime/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default defineNuxtPlugin({
}
}

const targetLocale = getLocaleFromRoute(to)
const targetLocale = getLocaleFromRoute(to) || options.defaultLocale
if (targetLocale && options.locales.includes(targetLocale)) {
useState<string>('locale').value = targetLocale
}
Expand Down

0 comments on commit fcac3bc

Please sign in to comment.