-
Notifications
You must be signed in to change notification settings - Fork 2.9k
feat: accept multiple locales in fallbackLocale #13822
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
base: main
Are you sure you want to change the base?
Conversation
📦 esbuild Bundle Analysis for payloadThis analysis was generated by esbuild-bundle-analyzer. 🤖
Largest pathsThese visualization shows top 20 largest paths in the bundle.Meta file: packages/next/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_index.json, Out file: esbuild/index.js
Meta file: packages/payload/meta_shared.json, Out file: esbuild/exports/shared.js
Meta file: packages/richtext-lexical/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_client.json, Out file: esbuild/exports/client_optimized/index.js
Meta file: packages/ui/meta_shared.json, Out file: esbuild/exports/shared_optimized/index.js
DetailsNext to the size is how much the size has increased or decreased compared with the base branch of this PR.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do we think?
| Option | Description | | ||
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| **`localizeStatus`** | **Boolean.** When `true`, shows document status per locale in the admin panel instead of always showing the latest overall status. Opt-in for backwards compatibility. Defaults to `false`. | | ||
| **`multipleFallbackLocales`** | **Boolean.** When `true`, allows `fallbackLocale` to accept an array of locales in find queries and locale configuration. Defaults to `false`. | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this needs to be behind an experimental flag. I'm guessing you might have done this because it would make for a new type union for plugins to deal with. The problem is that if a project uses this feature then the plugin will be broken either way as a result.
const fallbackValue = siblingDoc[field.name!][fallbackLocale] | ||
let fallbackValue | ||
const isNullOrUndefined = typeof value === 'undefined' || value === null | ||
console.log(experimental?.multipleFallbackLocales) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(:
What?
This change allows
fallbackLocale
to accept an array of locales in find queries and locale configuration.Why?
This update is part of the planned localization enhancements. Currently, only one fallback locale can be specified. If that locale doesn’t contain data, the query returns nothing. To work around this, users have to inspect the response themselves and then make additional queries for other locales.
With this change, Payload handles that work automatically. Users only need to provide a list of fallback locales in their preferred order, and Payload will check each one until it finds a value.
How?
Updates query handling across the local API, REST API, and GraphQL so that
fallbackLocale
can accept either a string or an array of locales. When an array is passed, Payload will iterate through them in order and return the first found localized value. This behavior applies to both collections and globals.Feature request: #13443