Skip to content

Commit

Permalink
fix: vueI18n resolution not using restructureDir defaults (#3159)
Browse files Browse the repository at this point in the history
  • Loading branch information
BobbieGoede authored Oct 5, 2024
1 parent 989d775 commit a016440
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
5 changes: 4 additions & 1 deletion specs/fixtures/empty_options/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// https://nuxt.com/docs/guide/directory-structure/nuxt.config
export default defineNuxtConfig({
compatibilityDate: '2024-04-03',
modules: ['@nuxtjs/i18n']
modules: ['@nuxtjs/i18n'],
i18n: {
restructureDir: false
}
})
4 changes: 0 additions & 4 deletions specs/fixtures/restructure/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,11 @@ export default defineNuxtConfig({
modules: [i18nModule, '@nuxtjs/i18n'],

i18n: {
restructureDir: false,
baseUrl: 'http://localhost:3000',
// langDir: 'lang',
// defaultLocale: 'fr',
detectBrowserLanguage: false,
compilation: {
strictMessage: false
},
restructureDir: 'i18n',
defaultLocale: 'en',
lazy: true,
locales: [
Expand Down
8 changes: 4 additions & 4 deletions src/layers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ export const mergeLayerPages = (analyzer: (pathOverride: string) => void, nuxt:
}

export function resolveI18nDir(layer: NuxtConfigLayer, i18n: NuxtI18nOptions, fromRootDir: boolean = false) {
if (i18n.restructureDir) {
return resolve(layer.config.rootDir, i18n.restructureDir)
if (i18n.restructureDir !== false) {
return resolve(layer.config.rootDir, i18n.restructureDir ?? 'i18n')
}

return resolve(layer.config.rootDir, fromRootDir ? '' : layer.config.srcDir)
Expand Down Expand Up @@ -153,9 +153,9 @@ export const getLayerLangPaths = (nuxt: Nuxt) => {

for (const layer of nuxt.options._layers) {
const i18n = getLayerI18n(layer)
if (!i18n?.restructureDir && i18n?.langDir == null) continue
if (i18n?.restructureDir === false && i18n?.langDir == null) continue

langPaths.push(resolveLayerLangDir(layer, i18n))
langPaths.push(resolveLayerLangDir(layer, i18n || {}))
}

return langPaths
Expand Down

0 comments on commit a016440

Please sign in to comment.