Skip to content

Commit 9cfd8ec

Browse files
committed
fix: handle falsy options.i18n types
1 parent c9b4529 commit 9cfd8ec

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/bundler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export function getDefineConfig(
6969

7070
// `stripMessagesPayload` is enabled by default when `experimental.preload` is set to true
7171
let stripMessagesPayload = !!options.experimental.preload
72-
if (nuxt.options.i18n?.experimental?.stripMessagesPayload != null) {
72+
if (nuxt.options.i18n && nuxt.options.i18n.experimental?.stripMessagesPayload != null) {
7373
stripMessagesPayload = nuxt.options.i18n.experimental.stripMessagesPayload
7474
}
7575

src/prepare/options.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,17 @@ export function prepareOptions({ options }: I18nNuxtContext, nuxt: Nuxt) {
1616
)
1717
}
1818

19-
if (nuxt.options.i18n?.autoDeclare && nuxt.options.imports.autoImport === false) {
19+
if (nuxt.options.i18n && nuxt.options.i18n.autoDeclare && nuxt.options.imports.autoImport === false) {
2020
logger.warn(
2121
'Disabling `autoImports` in Nuxt is not compatible with `autoDeclare`, either enable `autoImports` or disable `autoDeclare`.',
2222
)
2323
}
2424

25-
const strategy = nuxt.options.i18n?.strategy || options.strategy
26-
const defaultLocale = nuxt.options.i18n?.defaultLocale || options.defaultLocale
25+
const strategy = (nuxt.options.i18n && nuxt.options.i18n.strategy) || options.strategy
26+
const defaultLocale = (nuxt.options.i18n && nuxt.options.i18n.defaultLocale) || options.defaultLocale
2727
if (strategy.endsWith('_default') && !defaultLocale) {
2828
logger.warn(
29-
`The \`${strategy}\` i18n strategy${nuxt.options.i18n?.strategy == null ? ' (used by default)' : ''} needs \`defaultLocale\` to be set.`,
29+
`The \`${strategy}\` i18n strategy${(nuxt.options.i18n && nuxt.options.i18n.strategy) == null ? ' (used by default)' : ''} needs \`defaultLocale\` to be set.`,
3030
)
3131
}
3232

0 commit comments

Comments
 (0)