fix: correctly prioritize locales passed as null

This commit is contained in:
Jarrod Flesch
2024-02-05 10:52:33 -05:00
parent 175dc33b01
commit 6b666bf304

View File

@@ -43,11 +43,11 @@ export const createLocalReq: CreateLocalReq = (
const fallbackLocaleFromConfig = payload.config.localization.locales.find(
({ code }) => req.locale === code,
)?.fallbackLocale
const definedFallbackLocale = fallbackLocale || req?.fallbackLocale
req.fallbackLocale =
typeof definedFallbackLocale !== 'undefined'
? definedFallbackLocale
: fallbackLocaleFromConfig || defaultLocale
if (typeof fallbackLocale !== 'undefined') {
req.fallbackLocale = fallbackLocale
} else if (typeof req?.fallbackLocale === 'undefined') {
req.fallbackLocale = fallbackLocaleFromConfig || defaultLocale
}
}
req.context = getRequestContext(req, context)