Update components to allow for adding `lang` attributes to text
Summary
This relates to / is an extension of #4046.
Quite a few of our components allow text to be displayed but don't allow for lang attributes to be added to this text. All of the components which have this issue need updating in some way to allow this.
This ticket should probably involve exploring the best solution (might just be using slots but best to consider all options - may depend on the outcome for #4046), and then implementing this for all bits of text in all components (consider splitting this up into different tickets if this is a lot of work).
💬 Description
Developers may want to add the lang attribute to text to inform screen readers that certain words are in a different language, which will ensure they get pronounced correctly.
For some bits of text in our components, this is possible using slots, but in other areas, it is not possible at all because the text is either built-in or passed as a plain string using props. Some examples:
- Label on badges (which uses the
labelprop) - Label on breadcrumbs (which uses the
page-titleprop)
Developers may want to either add it to the whole piece of text or just certain words e.g.: <span lang="it">Vorrei un cappuccino</span> or <span>I'd like a <span lang="it">cappuccino</span></span>, so the solution needs to allow for this.
💰 Use value
This will ensure we meet the WCAG criterion 3.1.2 Language of Parts.
🚨 Urgency (low, medium or high)
Probably quite high urgency as the WCAG criterion this contributes towards is Level AA.
Additional info
It's important to check all screen reader behaviour works as these changes may have a big impact. Not sure if it will be completely possible to check with VoiceOver as mentioned in this comment.
Something to consider - do we need to also allow something similar for accessible text? E.g. something like the maxCharactersMessage on the text field - do we need to allow developer to add lang to words in this?
~~Might be best to leave this ticket until #4046 is done, as this ticket is a continuation of that. Also, whatever solution we decide to go with in that ticket, we should then probably implement with this - for consistency.~~
On second thoughts, it should probably be fine if someone were to work on this at the same time as #4046 - just as long as the same approach is used for consistency (e.g. slots or innerHTML). (That other ticket is more urgent though so prioritise working on it over this one)
I don't know if it will be necessary to allow this for every single bit of text in all our components. It's quite hard to tell as I would need to look through the code for all components - just something to keep in mind, but I think it will be the vast majority of text in components. Probably just worth assessing on a case by case basis
Initial spike is needed to identify what components need updating as part of this work, and what should be covered under I18n work. Create spike as child ticket.
Using the example <span>I'd like a <span lang="it">cappuccino</span></span> where cappuccino is a word that you might want to keep as Italian, these are the props that I think need equivalent slot across the components. I’ve added an example to each, happy to have push back on any that might be an edge case.
- [ ] Accordion group
- [ ]
accessibleButtonLabelprop -See all/Hide all <span lang=“it”>cappuccino</span>
- [ ]
- [ ] Action chip
- [ ]
labelprop -Confirm <span lang=“it”>cappuccino</span> order
- [ ]
- [ ] Alert
- [ ]
headingprop -<span lang=“it”>Cappuccino</span> order - [ ]
dismissLabelprop -Dismiss <span lang=“it”>Cappuccino</span> order
- [ ]
- [ ] Badge
- [ ]
labelprop -1 <span lang=“it”>Cappuccino</span> - [ ]
accessibleLabelprop -1 <span lang=“it”>Cappuccino</span> ready for collection
- [ ]
- [ ] Breadcrumb
- [ ]
pageTitleprop -<span lang=“it”>Cappuccino</span> orders
- [ ]
- [ ] Checkbox
- [ ]
dynamicTextprop -Would you like to add milk to your <span lang=“it”>cappuccino</span>? - [ ]
labelprop -1 <span lang=“it”>Cappuccino</span>(https://github.com/mi6/ic-ui-kit/pull/4085)
- [ ]
- [ ] Checkbox group
- [ ]
labelprop -What kind of milk would you like with your <span lang=“it”>cappuccino</span>?- REQUIRES CHANGE TO INPUT LABEL - [ ]
validationTextprop -There was an error ordering your <span lang=“it”>cappuccino</span>- REQUIRES CHANGE TO INPUT VALIDATION
- [ ]
- [ ] Chip
- [ ]
labelprop -1 <span lang=“it”>Cappuccino</span> - [ ]
dismissLabelprop -Dismiss <span lang=“it”>Cappuccino</span> order
- [ ]
- [ ] Classification banner
- [ ]
additionalSelectorsprop - Not got an example using cappuccino but it’s possible that we may need different languages in a classification banner
- [ ]
- [ ] Data table (Note: may need to reassess after https://github.com/mi6/ic-ui-kit/issues/1539)
- [ ]
captionprop -List of <span lang=“it”>cappuccino</span> orders - [ ]
loadingOptionsprop - Ific-loading-indicatorgets updated to slot content, then we should be able to slot the content into data table and pass it through - [ ]
paginationBarOptions- Ific-pagination-bar/ic-paginationget updated to slot content, then we should be able to slot the content into data table and pass it through
- [ ]
- [ ] Data table title bar
- [ ]
metadataprop -45 <span lang=“it”>cappuccinos</span> sold in 20 minutes
- [ ]
- [ ] Date input
- [ ]
disableDaysMessageprop -There are no <span lang=“it”>cappuccinos</span> on that day - [ ]
disableFutureMessageprop -There are no <span lang=“it”>cappuccinos</span> expected to be in stock in the future - [ ]
disablePastMessageprop -There were no <span lang=“it”>cappuccinos</span> in stock - [ ]
labelprop -What day would you like your <span lang=“it”>cappuccino</span>?- REQUIRES CHANGE TO INPUT LABEL - [ ]
validationTextprop -There was an error ordering your <span lang=“it”>cappuccino</span>- REQUIRES CHANGE TO INPUT VALIDATION - [ ] Clear button aria label - Does this need a
dismissLabelprop/slot like chip/alert etc.? -Dismiss <span lang=“it”>Cappuccino</span> order date
- [ ]
- [ ] Date picker
- [ ]
disableDaysMessageprop -There are no <span lang=“it”>cappuccinos</span> on that day - [ ]
disableFutureMessageprop -There are no <span lang=“it”>cappuccinos</span> expected to be in stock in the future - [ ]
disablePastMessageprop -There were no <span lang=“it”>cappuccinos</span> in stock - [ ]
labelprop -What day would you like your <span lang=“it”>cappuccino</span>?- REQUIRES CHANGE TO INPUT LABEL - [ ]
validationTextprop -There was an error ordering your <span lang=“it”>cappuccino</span>- REQUIRES CHANGE TO INPUT VALIDATION
- [ ]
- [ ] Dialog
- [ ]
dismissLabelprop -Dismiss <span lang=“it”>Cappuccino</span> order
- [ ]
- [ ] Divider
- [ ]
labelslot just needs documenting with@slotat the top of the file
- [ ]
- [ ] Footer
- [ ]
copyrightprop - https://github.com/mi6/ic-ui-kit/issues/4048
- [ ]
- [ ] Footer link group
- [ ]
labelprop -Notable <span lang=“it”>cappuccino</span> orders
- [ ]
- [ ] Input label
- [ ]
labelprop - Used in form components e.g. checkbox, radio, select etc. - NEEDS TO BE DONE FIRST
- [ ]
- [ ] Input validation
- [ ]
messageprop - Used in form components e.g. checkbox, radio, date input etc. - NEEDS TO BE DONE FIRST
- [ ]
- [ ] Loading indicator
- [ ]
descriptionprop -Loading <span lang=“it”>cappuccino</span> orders - [ ]
labelprop -Loading <span lang=“it”>cappuccino</span> orders
- [ ]
- [ ] Menu group
- [ ]
labelprop -Milk options for <span lang=“it”>cappuccino</span>
- [ ]
- [ ] Menu item
- [ ]
labelprop -<span lang=“it”>Cappuccino</span> to takeaway - [ ]
descriptionprop -A <span lang=“it”>cappuccino</span> is a type of coffee made with espresso and milk that has been frothed up
- [ ]
- [ ] Navigation button
- [ ]
labelprop -<span lang=“it”>Cappuccino</span> order form
- [ ]
- [ ] Navigation group
- [ ]
labelprop -<span lang=“it”>Cappuccino</span> orders
- [ ]
- [ ] Navigation menu
- [ ]
statusprop -1 <span lang=“it”>Cappuccino</span> - [ ]
versionprop - If we’re adding a slot for the status, we probably should for version, but probably not for i18n purposes
- [ ]
- [ ] Pagination
- [ ]
labelprop -<span lang=“it”>Cappuccino</span> order no. 6 - [ ] Screen reader only text “page ${this.currentPage}” is hard coded, but if we’re adding a
labelslot and thelabelprop currently changes the word “page”, does this not need updating to “${this.label} ${this.currentPage}”?
- [ ]
- [ ] Pagination bar
- [ ]
itemLabelprop -<span lang=“it”>Cappuccino</span> order no. 6 - [ ]
pageLabelprop -<span lang=“it”>Cappuccino</span> order no. 6
- [ ]
- [ ] Pagination item
- [ ]
labelprop -<span lang=“it”>Cappuccino</span> order no. 6
- [ ]
- [ ] Radio group
- [ ]
labelprop -What kind of milk would you like with your <span lang=“it”>cappuccino</span>?- REQUIRES CHANGE TO INPUT LABEL - [ ]
validationTextprop -There was an error ordering your <span lang=“it”>cappuccino</span>- REQUIRES CHANGE TO INPUT VALIDATION
- [ ]
- [ ] Radio option
- [ ]
dynamicTextprop -Would you like to add milk to your <span lang=“it”>cappuccino</span>? - [ ]
labelprop -1 <span lang=“it”>Cappuccino</span>
- [ ]
- [ ] Search bar
- [ ]
emptyOptionListTextprop -No <span lang=“it”>cappuccino</span> orders - [ ]
labelprop -What kind of milk would you like with your <span lang=“it”>cappuccino</span>?- REQUIRES CHANGE TO INPUT LABEL - [ ]
loadingErrorLabelprop -Cannot load <span lang=“it”>cappuccino</span> orders - [ ]
loadingLabelprop -Loading <span lang=“it”>cappuccino</span> orders - [ ]
placeholderprop -Search <span lang=“it”>cappuccino</span> orders - [ ] Clear button aria label - Does this need a
dismissLabelprop/slot like chip/alert etc.? -Clear <span lang=“it”>Cappuccino</span> order search
- [ ]
- [ ] Select
- [ ]
emptyOptionListTextprop -No <span lang=“it”>cappuccino</span> orders - [ ]
labelprop -What kind of milk would you like with your <span lang=“it”>cappuccino</span>?- REQUIRES CHANGE TO INPUT LABEL - [ ]
loadingErrorLabelprop -Cannot load <span lang=“it”>cappuccino</span> orders - [ ]
loadingLabelprop -Loading <span lang=“it”>cappuccino</span> orders - [ ]
placeholderprop -Select a <span lang=“it”>cappuccino</span> order - [ ]
validationTextprop -There was an error ordering your <span lang=“it”>cappuccino</span>- REQUIRES CHANGE TO INPUT VALIDATION - [ ] Clear button aria label - Does this need a
dismissLabelprop/slot like chip/alert etc.? -Clear <span lang=“it”>Cappuccino</span> order
- [ ]
- [ ] Side navigation
- [ ]
statusprop -1 <span lang=“it”>Cappuccino</span> - [ ]
versionprop - If we’re adding a slot for the status, we probably should for version, but probably not for i18n purposes
- [ ]
- [ ] Skip link
- [ ]
labelprop -Skip to <span lang=“it”>Cappuccino</span> orders
- [ ]
- [ ] Status tag
- [ ]
labelprop -1 <span lang=“it”>Cappuccino</span>
- [ ]
- [ ] Step
- [ ]
headingprop -<span lang=“it”>cappuccino</span> order step 1 - [ ]
subheadingprop -Order your <span lang=“it”>cappuccino</span> here
- [ ]
- [ ] Switch
- [ ]
labelprop -Add more milk to your <span lang=“it”>cappuccino</span>?- REQUIRES CHANGE TO INPUT LABEL
- [ ]
- [ ] Table of contents
- [ ]
headingprop -<span lang=“it”>Cappuccino</span> order form page
- [ ]
- [ ] Text field
- [ ]
labelprop -What type of milk would you like in your <span lang=“it”>cappuccino</span>?- REQUIRES CHANGE TO INPUT LABEL - [ ]
placeholderprop -Review your <span lang=“it”>cappuccino</span> order - [ ]
validationTextprop -There was an error ordering your <span lang=“it”>cappuccino</span>- REQUIRES CHANGE TO INPUT VALIDATION
- [ ]
- [ ] Time input
- [ ]
labelprop -What time would you like your <span lang=“it”>cappuccino</span>?- REQUIRES CHANGE TO INPUT LABEL - [ ]
invalidTimeMessageprop -We do not serve <span lang=“it”>cappuccinos</span> at this time - [ ]
validationTextprop -There was an error ordering your <span lang=“it”>cappuccino</span>- REQUIRES CHANGE TO INPUT VALIDATION - [ ] Clear button aria label - Does this need a
dismissLabelprop/slot like chip/alert etc.? -Dismiss <span lang=“it”>Cappuccino</span> order time
- [ ]
- [ ] Toast
- [ ]
headingprop -Thanks for ordering a <span lang=“it”>cappuccino</span> - [ ]
messageprop -Your <span lang=“it”>cappuccino</span> will be with you shortly
- [ ]
- [ ] Toggle button
- [ ]
labelprop -<span lang=“it”>Cappuccino</span> order no. 1
- [ ]
- [ ] Tooltip
- [ ]
labelprop -<span lang=“it”>Cappuccino</span> with extra frothy milk
- [ ]
- [ ] Top navigation
- [ ]
statusprop -1 <span lang=“it”>Cappuccino</span> - [ ]
versionprop - If we’re adding a slot for the status, we probably should for version, but probably not for i18n purposes
- [ ]