feat(core): pass locale
to custom preview templates
#5912
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #5911
Summary
Pass the currently selected locale to the editor preview pane to allow custom preview templates to adapt to different locales (see #5911).
Test plan
I created a collection in
dev-test/config.yml
with i18n enabled.In
dev-test/index.html
I registered a custom preview template to display the passedlocale
prop:The locale string displayed in the preview pane and toggling between the locale currently being edited updated the preview string.
I’d love to add an integration test for a custom preview template and check the props it receives, but I couldn’t see any existing tests for this.
Checklist
Please add a
x
inside each checkbox:yarn format
.yarn test
.A picture of a cute animal (not mandatory but encouraged)
A locale locust:
By Charles J. Sharp - Own work, from Sharp Photography, sharpphotography, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=59068817