-
I couldn't find an example or discussion about this topic. Does A simple example would be: A Post has multiple Authors. I'd like generate markup to link to each Author from that Post in a localized list (carriage return added for readability here): <h1>Post Title</h1>
<p>
<a href="/author/1">Author One</a>,
<a href="/author/2">Author Two</a>, and
<a href="/author/3">Author Three</a>
</p> It seems like something like the following would work, but the const f = useFormatter();
const output = f.list(
[
<Link href="/author/1">Author One</Link>,
<Link href="/author/2">Author Two</Link>,
<Link href="/author/3">Author Three</Link>,
],
{ type: "conjunction" }
);
Did I miss something obvious? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
Hey, thanks for the great question, this is indeed missing currently! It's somewhat related to #774, but I'm wondering if this could be supported with the existing I tried a quick example: const vehicles = ['Motorcycle', 'Car', <p>Bus</p>];
const formatterEn = new Intl.ListFormat('en', {
style: 'long',
type: 'conjunction'
});
const partValuesEn = formatterEn
.formatToParts(vehicles)
.map((p) => p.value); This doesn't seem to work due to:
I think this would require some research on how Would you be interested in looking into this? |
Beta Was this translation helpful? Give feedback.
Sure, no worries!
I had a moment to have a look at the implementation from
react-intl
:…where
generateToken
simply creates an id based on the index of elements in case of rich text values.The spec on the
values
that formatting functions fromListFormat
accept only has this information in regard to the limitation of strings:Based on this, I think we can be a bit more flexible like
react-intl
does and a…