chore: align fallbackLocale determination with new fallbackLocale property on Locale
This commit is contained in:
@@ -303,6 +303,10 @@ export type Locale = {
|
||||
* @example "en"
|
||||
*/
|
||||
code: string
|
||||
/**
|
||||
* Code of another locale to use when reading documents with fallback, if not specified defaultLocale is used
|
||||
*/
|
||||
fallbackLocale?: string
|
||||
/**
|
||||
* label of supported locale
|
||||
* @example "English"
|
||||
|
||||
@@ -40,7 +40,11 @@ export const createLocalReq: CreateLocalReq = (
|
||||
if (payload.config?.localization) {
|
||||
const defaultLocale = payload.config.localization.defaultLocale
|
||||
req.locale = locale || req?.locale || defaultLocale
|
||||
req.fallbackLocale = fallbackLocale || req?.fallbackLocale || defaultLocale
|
||||
const fallbackLocaleFromConfig = payload.config.localization.locales.find(
|
||||
({ code }) => req.locale === code,
|
||||
)?.fallbackLocale
|
||||
req.fallbackLocale =
|
||||
fallbackLocale || req?.fallbackLocale || fallbackLocaleFromConfig || defaultLocale
|
||||
}
|
||||
|
||||
req.context = getRequestContext(req, context)
|
||||
|
||||
Reference in New Issue
Block a user