Rendering ordered/unordered lists from a translation string.
See original GitHub issue🚀 Feature Proposal
I searched quite a while but couldn’t find a way to render basic HTML lists. Is there a recommended way output a plain HTML list from a translation string?
I did found the i18nIsDynamicList
example, but that does not allow me to render content from the same translation string that is passed as key
to the Trans component.
Motivation
I am using the Trans component with children to render dynamic and translated content. The dynamic content does require me to support adding ordered and unordered lists.
Example
Im looking for something in the likes of:
<Trans i18nKey="list_map">
My cats are named:
<ul>
<li>Milo</li>
<li>Simba</li>
</ul>
and they are very sweet.
</Trans>
// JSON -> "list_map": "My dogs are named: <1><2>Ace</2><2>Diesel</2><2>Finn</2></1>"
// Which would output:
// My dogs are named:
// <ul>
// <li>Ace</li>
// <li>Diesel</li>
// <li>Finn</li>
// </ul>
// and they are very sweet.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
l10n/i18n: how to handle phrases with dynamic list of items?
To render a list, I would use a couple of format strings, e.g.: joinItem = "{LIST}, {ITEM}" to append items to the list...
Read more >apex - Render Set as Unordered List - Salesforce Stack Exchange
Sets are unordered lists that don't contain duplicates. ... If you need an ordered list you should use a List<String> collection.
Read more >list-style - CSS: Cascading Style Sheets - MDN Web Docs
The list-style CSS shorthand property allows you to set all the list ... Safari will not recognize an ordered or unordered list as...
Read more >Lists in HTML documents
Ordered and unordered lists are rendered in an identical manner except that visual user agents number ordered list items. User agents may present...
Read more >List Rendering - Vue.js
We can use the v-for directive to render a list of items based on an array. ... The iteration order will be based...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thanks for your quick reply. I managed to create a working solution by updating the nested index elements to 0. I did not now that nested children would reset its index to 0.
how can I iterate array elements to unrodered list with map
when I do this it gives me t(…).map is not a function