Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: i18n locale and config macro undefined on server-side #3337

Merged
merged 3 commits into from
Feb 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions src/nitro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,30 +90,32 @@ export { localeDetector }
debug('nitro.replace', nitroConfig.replace)
})

// `defineI18nLocale` and `defineI18nConfig`
addServerImports([
...[NUXT_I18N_COMPOSABLE_DEFINE_LOCALE, NUXT_I18N_COMPOSABLE_DEFINE_CONFIG].map(key => ({
name: key,
as: key,
from: resolver.resolve('runtime/composables/shared')
}))
])

if (enableServerIntegration) {
// `@intlify/utils/h3`, `defineI18nLocale` and `defineI18nConfig`
// `@intlify/utils/h3` and `defineLocaleDetector
const h3UtilsExports = await resolveModuleExportNames(UTILS_H3_PKG, { url: import.meta.url })
addServerImports([
...h3UtilsExports.map(key => ({
name: key,
as: key,
from: resolver.resolve(nuxt.options.alias[UTILS_H3_PKG])
})),
...[NUXT_I18N_COMPOSABLE_DEFINE_LOCALE, NUXT_I18N_COMPOSABLE_DEFINE_CONFIG].map(key => ({
name: key,
as: key,
from: resolver.resolve('runtime/composables/shared')
})),
{
name: NUXT_I18N_COMPOSABLE_DEFINE_LOCALE_DETECTOR,
as: NUXT_I18N_COMPOSABLE_DEFINE_LOCALE_DETECTOR,
from: resolver.resolve('runtime/composables/server')
}
])
}

// add nitro plugin
if (enableServerIntegration) {
// add nitro plugin
addServerPlugin(resolver.resolve('runtime/server/plugin'))
}
}
Expand Down