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

fix(i18n): allow list formatter without arguments in Translate component #6135

Merged
merged 2 commits into from Mar 27, 2024

Conversation

rexxars
Copy link
Member

@rexxars rexxars commented Mar 26, 2024

Description

It seems we used a formatter in a resource passed to <Translate>, which won't work as the "simple parser" does not reimplement all the logic from i18next. I initially did an approach where I changed the key to not use a formatter, but it quickly got a bit messy to think about whether the key should be a new key, and how to reason about old versions of it.

Instead, I chose to implement partial support for formatters inside of the Translate component - currently only for the list formatter, and only without arguments. In time we can see if we can expand on this, but this fixes #6003 and moves us a bit forward at least.

What to review

  • Code makes sense
  • There aren't any regressions in how this works

Testing

  • Added tests for both parser and for the Translate function

Notes for release

  • Fixed an issue where the studio might crash on "orphaned marks" in the Portable Text Editor

@rexxars rexxars requested a review from a team as a code owner March 26, 2024 19:17
@rexxars rexxars requested review from juice49 and removed request for a team March 26, 2024 19:17
Copy link

vercel bot commented Mar 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview Mar 27, 2024 4:35pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 27, 2024 4:35pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Mar 27, 2024 4:35pm

Copy link
Contributor

No changes to documentation

Copy link
Contributor

github-actions bot commented Mar 26, 2024

Component Testing Report Updated Mar 27, 2024 4:39 PM (UTC)

File Status Duration Passed Skipped Failed
comments/CommentInput.spec.tsx ✅ Passed (Inspect) 31s 15 0 0
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 6s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 12s 3 0 0
formBuilder/inputs/PortableText/copyPaste/CopyPaste.spec.tsx ✅ Passed (Inspect) 12s 4 2 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 12s 6 0 0
formBuilder/inputs/PortableText/FocusTracking.spec.tsx ✅ Passed (Inspect) 33s 15 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 1m 1s 15 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 1m 2s 18 0 0
formBuilder/inputs/PortableText/RangeDecoration.spec.tsx ✅ Passed (Inspect) 12s 6 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 13s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ❌ Failed (Inspect) 24s 8 0 1

Copy link
Contributor

@juice49 juice49 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

packages/sanity/src/core/i18n/Translate.tsx Outdated Show resolved Hide resolved
Co-authored-by: Ash <ash@sanity.io>
@rexxars rexxars merged commit 3e5b8d6 into next Mar 27, 2024
35 of 36 checks passed
@rexxars rexxars deleted the fix/orphaned-marks-i18n-warning branch March 27, 2024 16:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants