IPP CTA locations with i18n listFormat approach to support many more locations#7068
Closed
allthesignals wants to merge 8 commits intomainfrom
Closed
IPP CTA locations with i18n listFormat approach to support many more locations#7068allthesignals wants to merge 8 commits intomainfrom
allthesignals wants to merge 8 commits intomainfrom
Conversation
Includes updates to FR, ES, and EN locales.
Co-authored-by: Andrew Duthie <andrew.duthie@gsa.gov>
allthesignals
commented
Sep 30, 2022
| */ | ||
| const toI18nList = (list) => { | ||
| const nonBreakingListItems = list.map(nonBreaking); | ||
| const i18nList = new Intl.ListFormat('en', { type: 'disjunction', style: 'short' }); |
Contributor
Author
There was a problem hiding this comment.
Would need to configure the locale (not sure how that's inferred inside this component yet).
Contributor
Author
There was a problem hiding this comment.
Separately, there is a way to extract parts of the formatted list and manipulate spacing accordingly. That would lend itself to some complex string manipulation/regex, and I wanted to check on this approach before looking any further!
1 task
Contributor
Author
|
Closing in favor of #7069 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
🎫 Ticket
Addresses 7620
🛠 Summary of changes
For the IPP CTA list of locations, this PR implements a dynamic approach to internationalizing a list of locations, with some tradeoffs. This approach favors one that separates content from presentation.
This approach uses a centralized location list and interpolates the surrounding language in a locale file entry. The formatting and translation of the list logic uses Intl to both translate the disjunction and insert commas accordingly. Further, this inserts non-breaking spaces in the original list, preventing line breaks from occuring between city/state names.
The biggest drawback is that manipulating spacing around the disjunctive term gets a little sloppy. We would need to insert a non-breaking space after the disjunction to preserve the correct design.
Keeping this as a draft to see if this makes sense before going any further.
👀 Screenshots
If relevant, include a screenshot or screen capture of the changes.
After:
More than two:

Two list items:
