nuxt-modules / i18n

I18n module for Nuxt
https://i18n.nuxtjs.org
MIT License
1.65k stars 465 forks source link

[BUG?]: Locale resolver scans `srcDir` instead of `rootDir` #2983

Open Gerbuuun opened 1 week ago

Gerbuuun commented 1 week ago

In Nuxt 4 the srcDir will be app by default instead of being the same as the rootDir. I want to put my lang directory outside of the app directory because I also use translations server side.

In the module setup it will scan the srcDir for the translation files but they are located outside of it. https://github.com/nuxt-modules/i18n/blob/cddb8b31825405f08f569f882b6d80284c263ca7/src/module.ts#L184-L188

(The experimental.localeDetector, in contrast, does scan the rootDir) https://github.com/nuxt-modules/i18n/blob/cddb8b31825405f08f569f882b6d80284c263ca7/src/nitro.ts#L138

I tested the module with only changing the nuxt.options.srcDir to nuxt.options.rootDir and it works fine. I hope this is the easy fix I think it is.

cc @danielroe

Gerbuuun commented 1 week ago

Just realized I can use a relative path in the config.

i18n: {
  langDir: '../lang',
}

A point on consistency could still be made though.

kazupon commented 1 week ago

Thank you for your reporting! We are now going to work on nuxt-i18n v9. At that time we will also test it with nuxt4. Please wait!