-
-
Notifications
You must be signed in to change notification settings - Fork 15
Description
Describe the bug
Hello, the localePath
method from i18n and all its derivative (NuxtLinkLocale for instance) always returns an empty string when the current locale is the default one.
The method works again when nuxt-typed-router is removed from the modules.
I am using prefix_and_default
as my i18n strategy and the latest version of nuxt-typed-router.
After some digging, it seems that nuxt-typed-router removes the ___[locale]___default
suffix from the default route name, but i18n still localizes the route by suffixing with ___[locale]___default
when using the default locale, causing the resolver to throw an error as there are no match found.
Thank you for your work on this module, it is really helpful!
Expected behavior
the localePath
method and its derivative should return the correct path if am using the prefix_and_defaut
strategy even if I am using the default locale.
Screenshots
Logs from the execution of
localePath
andresolveRoute
in i18n using the default localefr
and the route/log-in
, the route is localized tolog-in___fr___default
, which is not found by the router.
List of registered routes in nuxt dev tools, the
/log-in
route lacks the___fr___default
suffix.
The same list without nuxt-typed-router registered, the
/log-in
route has the correct name
Environnement infos
------------------------------
- Operating System: Windows_NT
- Node Version: v20.9.0
- Nuxt Version: 3.12.0
- CLI Version: 3.11.1
- Nitro Version: 2.9.6
- Package Manager: bun@1.1.12
- Builder: -
- User Config: devtools, typescript, app, modules, css, $development, primevue, eslint, i18n
- Runtime Modules: @nuxtjs/tailwindcss@6.12.0, @nuxt/eslint@0.3.13, @vueuse/nuxt@10.10.0, nuxt-primevue@3.0.0, @nuxtjs/i18n@8.3.1, @pinia/nuxt@0.5.1
- Build Modules: -
------------------------------
Your pages
folder structure
pages
├── grpd.vue
├── index.vue
├── log-in
│ └── index.vue
├── register
│ └── index.vue
└── sales
└── [uuid].vue
Your nuxt.config.ts
nuxt.config.ts
modules: [
'@nuxtjs/tailwindcss',
'@nuxt/eslint',
'@vueuse/nuxt',
'nuxt-primevue',
'@nuxtjs/i18n',
'@pinia/nuxt',
],
i18n: {
vueI18n: './i18n.config.ts', // if you are using custom path, default
locales: [
{
code: 'en',
file: 'en-US.ts',
},
{
code: 'fr',
file: 'fr-FR.ts',
},
],
defaultLocale: 'fr',
strategy: 'prefix_and_default',
lazy: true,
langDir: 'lang',
},
i18n.config.ts
export default defineI18nConfig(() => ({
legacy: false,
locale: 'fr',
}));