Skip to content
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

Access current locale in Custom Preview Template #5911

Closed
delucis opened this issue Oct 20, 2021 · 0 comments · Fixed by #5912
Closed

Access current locale in Custom Preview Template #5911

delucis opened this issue Oct 20, 2021 · 0 comments · Fixed by #5912
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality

Comments

@delucis
Copy link
Contributor

delucis commented Oct 20, 2021

When adding a custom preview template with i18n, the template does not seem to receive a prop/data entry to indicate the current locale. This was requested in #5337, but the fix for that (#5875) only made sure the preview refreshes to receive the current locale content. For many cases, this is probably enough, but sometimes having the locale itself is helpful (i.e. the string 'en', 'zh', etc.). For example, the preview template might need to apply RTL/LTR classes or localize dates depending on the locale.

Describe the solution you'd like
A custom preview component should receive locale either as a prop or as metadata somewhere in the entry data.

Describe alternatives you've considered
Current alternatives would include trying to guess the locale from the content or duplicating data by adding a locale field to entries.

@delucis delucis added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant