-
Notifications
You must be signed in to change notification settings - Fork 4
[Nuxt] Locales not found with nested directories, specifically layers #6
Description
Stack
nuxt@4.2.1
@nuxtjs/i18n@10.2.1
Description
It seems that the locales paths aren't found when using Nuxt layers, but are found when using pre-defined paths like src/lang/en.json since it seems to be hardcoded in the extension's code.
Here's an example of my project structure using nuxt layers:
layers/
|
foo/
-> i18n/en.json
-> nuxt.config.ts
Contents of nuxt.config.ts
import { i18n } from '../../infrastructure/localization';
export default defineNuxtConfig({ i18n });Contents of localization.ts
import type { ModuleOptions } from '@nuxtjs/i18n';
import { Locale } from './types/locales.type';
export const i18n: ModuleOptions = {
defaultLocale: Locale.FrFr,
strategy: 'prefix_except_default',
locales: [
{ code: Locale.FrFr, language: Locale.FrFr, file: 'fr.json' },
{ code: Locale.EnUs, language: Locale.EnUs, file: 'en.json' },
],
};Note that this config is used in every single layer I have and that everything works perfectly fine using i18n-ally on VSCode.
How to reproduce
Setup a nuxtjs project using the specified version in the stack and don't forget nuxt i18n.
Create a dummy layer using from the description above, and see if the path is found.
Try to create a src/lang/en.json path to make sure that one works, then try nested directory using layers. You will then notice that locales are not found anymore, whether you add the full path or a regex that finds every file e.g.
["**/*/i18n/locales"]
Note that the regex above works perfectly on i18n-ally, if you can base your fix on that, perhaps ?