Skip to content

Commit 88a29b5

Browse files
authoredFeb 2, 2025
fix: i18n locale and config macro undefined on server-side (#3337)
1 parent 89f4a40 commit 88a29b5

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed
 

‎src/nitro.ts

+11-9
Original file line numberDiff line numberDiff line change
@@ -90,30 +90,32 @@ export { localeDetector }
9090
debug('nitro.replace', nitroConfig.replace)
9191
})
9292

93+
// `defineI18nLocale` and `defineI18nConfig`
94+
addServerImports([
95+
...[NUXT_I18N_COMPOSABLE_DEFINE_LOCALE, NUXT_I18N_COMPOSABLE_DEFINE_CONFIG].map(key => ({
96+
name: key,
97+
as: key,
98+
from: resolver.resolve('runtime/composables/shared')
99+
}))
100+
])
101+
93102
if (enableServerIntegration) {
94-
// `@intlify/utils/h3`, `defineI18nLocale` and `defineI18nConfig`
103+
// `@intlify/utils/h3` and `defineLocaleDetector
95104
const h3UtilsExports = await resolveModuleExportNames(UTILS_H3_PKG, { url: import.meta.url })
96105
addServerImports([
97106
...h3UtilsExports.map(key => ({
98107
name: key,
99108
as: key,
100109
from: resolver.resolve(nuxt.options.alias[UTILS_H3_PKG])
101110
})),
102-
...[NUXT_I18N_COMPOSABLE_DEFINE_LOCALE, NUXT_I18N_COMPOSABLE_DEFINE_CONFIG].map(key => ({
103-
name: key,
104-
as: key,
105-
from: resolver.resolve('runtime/composables/shared')
106-
})),
107111
{
108112
name: NUXT_I18N_COMPOSABLE_DEFINE_LOCALE_DETECTOR,
109113
as: NUXT_I18N_COMPOSABLE_DEFINE_LOCALE_DETECTOR,
110114
from: resolver.resolve('runtime/composables/server')
111115
}
112116
])
113-
}
114117

115-
// add nitro plugin
116-
if (enableServerIntegration) {
118+
// add nitro plugin
117119
addServerPlugin(resolver.resolve('runtime/server/plugin'))
118120
}
119121
}

0 commit comments

Comments
 (0)