Skip to content

IPP CTA locations with i18n listFormat approach to support many more locations#7068

Closed
allthesignals wants to merge 8 commits intomainfrom
wmg/7620-ipp-cta-locations
Closed

IPP CTA locations with i18n listFormat approach to support many more locations#7068
allthesignals wants to merge 8 commits intomainfrom
wmg/7620-ipp-cta-locations

Conversation

@allthesignals
Copy link
Contributor

@allthesignals allthesignals commented Sep 30, 2022

🎫 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:
Sep-30-2022 17-35-25

Two list items:
Sep-30-2022 17-31-49

@allthesignals allthesignals changed the title IPP CTA locations with i18n listFormat approach IPP CTA locations with i18n listFormat approach to support many more locations Sep 30, 2022
@allthesignals allthesignals requested a review from aduth September 30, 2022 22:41
*/
const toI18nList = (list) => {
const nonBreakingListItems = list.map(nonBreaking);
const i18nList = new Intl.ListFormat('en', { type: 'disjunction', style: 'short' });
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Would need to configure the locale (not sure how that's inferred inside this component yet).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

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!

@allthesignals
Copy link
Contributor Author

Closing in favor of #7069

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