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

Refactor manifesto initialization to push property localization down #4054

Merged
merged 4 commits into from
Jan 10, 2025

Conversation

cbeer
Copy link
Collaborator

@cbeer cbeer commented Dec 17, 2024

Take 3.

From #3871:

From #3482:

A recent change in the Manifesto library made it possible to pass a list of languages (in descending order of preference) to the PropertyValue.getValue and PropertyValue.getValues methods, instead of relying on a single default locale that would be set when parsing the manifest. This allows for a better user experience, since we can now dynamically respond to changes in the user's language preferences without having to re-parse the manifest. Additionally, we can make use of the browser's language preferences to better match the user's language abilities.

This does the same thing as #3482, without introducing new redux state or a new selector parameter, in order to maintain API compatibility for downstream plugins. Instead, this PR:

  • introduces a LocaleContext and locale-context aware IIIFResourceLabel for rendering e.g. manifest, canvas, etc labels appropriately, replacing a lot of piece-meal label functions
  • ensures components within a companion window include that context when calling selectors (to get the getLocale/getManifestLocale to work right... this is somewhat unfortunate, but probably less weird if we started to use hooks or more extensive use of context like Use context to pass the window id around #3661 (and a companion-window equivalent))
  • Clean up styling for the companion window locale picker to make it more like the workspace language selector

This can be tested at https://deploy-preview-4054--mirador-dev.netlify.app/__tests__/integration/mirador/i18n.html

Fixes #3470

Copy link

codecov bot commented Dec 17, 2024

Codecov Report

Attention: Patch coverage is 95.83333% with 6 lines in your changes missing coverage. Please review.

Project coverage is 94.59%. Comparing base (f04609f) to head (d947941).
Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
src/components/WindowSideBarCollectionPanel.js 0.00% 3 Missing ⚠️
src/components/CollectionDialog.js 50.00% 2 Missing ⚠️
src/components/WindowSideBarCanvasPanel.js 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4054      +/-   ##
==========================================
+ Coverage   94.52%   94.59%   +0.06%     
==========================================
  Files         313      315       +2     
  Lines       14773    14756      -17     
  Branches     2496     2491       -5     
==========================================
- Hits        13964    13958       -6     
+ Misses        804      794      -10     
+ Partials        5        4       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@cbeer cbeer marked this pull request as ready for review December 17, 2024 16:22
@cbeer cbeer force-pushed the manifest-getValue-locale2 branch 3 times, most recently from 654d55f to c92dd06 Compare December 18, 2024 22:26
@cbeer cbeer force-pushed the manifest-getValue-locale2 branch from c605e0f to d947941 Compare January 8, 2025 23:19
Copy link
Member

@marlo-longley marlo-longley left a comment

Choose a reason for hiding this comment

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

This works for me locally and in the Netlify preview.

@cbeer cbeer merged commit 40f05d2 into main Jan 10, 2025
9 checks passed
@cbeer cbeer deleted the manifest-getValue-locale2 branch January 10, 2025 19:52
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.

Multilingual manifest labels
2 participants