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

feat(i18n): localize global search filters and results #5108

Merged
merged 7 commits into from
Nov 3, 2023

Conversation

rexxars
Copy link
Member

@rexxars rexxars commented Nov 2, 2023

Description

This localizes all the different search filters, as well as the results list and orderings.
In doing so, I had the need to format both units and date/time, so I introduced two new hooks:

  • useIntlDateTimeFormat - the same as the other useIntl* hooks, it uses the memoized cache of formatters and returns a date/time formatter based on the current locale.
  • useUnitFormatter - basically the same as the other useIntl* hooks, but I found it very tedious to have to call useNumberFormat three times if I wanted to format days, months and years - so I decided to make one that simply does this behind the scenes. It's all memoized anyway.

You'll notice that the naming on the latter hook does not include the Intl part, and lives in core, not i18n. I am starting to lean in the direction that none of these hooks should include the Intl part, as localizing should be the default for the studio, not an opt-in kind of thing. Would be interested in hearing opinions here.

@robinpyon I may have butchered the beautiful work you've put into the search filters as I tried to ensure that the labels could be localized. Blown away by the amount of work you've put into the search feature ❤️

Lastly, the "debug triangles" were affecting the layout a bit to much in some cases, so I introduced a new debug mode that uses a right to left modifier symbol - it basically inverts all the text. This mode means there are little to no layout changes compared to normal, and it is still fairly easy to see what is localized and not (either they are dynamic strings, or they are yet to be localized).

Known issues/limitations

  • The date/time filter currently does not format the input values according to locale. The reason for this is that it also includes parsing of that format, eg it tries to parse "Oct 13, 2023" back to a value. It is unclear to me at this time how we'll want to approach this.
  • I discovered a few issues with the calendar navigation as I was using it that I have not discovered before - it may be related to timezones. Have reproduced the issue on next, so will not address it in this PR.
  • Certain elements from @sanity/ui have built-in aria labels that I was not able to localize. Have raised this as a concern and will address it separately.

What to review

  • Search filters work and show correct values

@rexxars rexxars requested review from robinpyon and a team November 2, 2023 02:02
@rexxars rexxars requested a review from bjoerge as a code owner November 2, 2023 02:02
Copy link

vercel bot commented Nov 2, 2023

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

Name Status Preview Comments Updated (UTC)
performance-studio ✅ Ready (Inspect) Visit Preview Nov 3, 2023 6:14pm
test-studio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 3, 2023 6:14pm
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
studio-workshop ⬜️ Ignored (Inspect) Visit Preview Nov 3, 2023 6:14pm

Copy link
Contributor

github-actions bot commented Nov 2, 2023

Package Documentation Change
sanity +19%
@sanity/types +2%
sanity/desk +2%
Full Report
sanity
This branch Next branch
144 documented 122 documented
845 not documented 831 not documented
@sanity/types
This branch Next branch
54 documented 53 documented
233 not documented 233 not documented
sanity/desk
This branch Next branch
84 documented 83 documented
56 not documented 55 not documented
@sanity/diff
This branch Next branch
13 documented 13 documented
16 not documented 16 not documented
@sanity/block-tools
This branch Next branch
4 documented 4 documented
9 not documented 9 not documented
@sanity/portable-text-editor
This branch Next branch
21 documented 21 documented
44 not documented 44 not documented
@sanity/mutator
This branch Next branch
7 documented 7 documented
4 not documented 4 not documented
@sanity/cli
This branch Next branch
1 documented 1 documented
30 not documented 30 not documented
@sanity/schema/_internal
This branch Next branch
0 documented 0 documented
9 not documented 9 not documented
@sanity/util/paths
This branch Next branch
1 documented 1 documented
15 not documented 15 not documented
sanity/router
This branch Next branch
15 documented 15 documented
21 not documented 21 not documented
@sanity/util/legacyDateFormat
This branch Next branch
0 documented 0 documented
3 not documented 3 not documented
@sanity/schema
This branch Next branch
0 documented 0 documented
2 not documented 2 not documented
sanity/cli
This branch Next branch
2 documented 2 documented
0 not documented 0 not documented
@sanity/vision
This branch Next branch
0 documented 0 documented
2 not documented 2 not documented
@sanity/util/fs
This branch Next branch
0 documented 0 documented
3 not documented 3 not documented
sanity/_internal
This branch Next branch
0 documented 0 documented
1 not documented 1 not documented
@sanity/util/content
This branch Next branch
1 documented 1 documented
5 not documented 5 not documented

Copy link
Contributor

github-actions bot commented Nov 2, 2023

Component Testing Report Updated Nov 3, 2023 6:15 PM (UTC)

File Status Duration Passed Skipped Failed
formBuilder/ArrayInput.spec.tsx ✅ Passed (Inspect) 8s 3 0 0
formBuilder/inputs/PortableText/Annotations.spec.tsx ✅ Passed (Inspect) 9s 3 0 0
formBuilder/inputs/PortableText/Decorators.spec.tsx ✅ Passed (Inspect) 9s 6 0 0
formBuilder/inputs/PortableText/Input.spec.tsx ✅ Passed (Inspect) 13s 9 0 0
formBuilder/inputs/PortableText/ObjectBlock.spec.tsx ✅ Passed (Inspect) 45s 18 0 0
formBuilder/inputs/PortableText/Styles.spec.tsx ✅ Passed (Inspect) 10s 6 0 0
formBuilder/inputs/PortableText/Toolbar.spec.tsx ✅ Passed (Inspect) 5s 3 0 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant