Make WordPress Core

Opened 8 years ago

Closed 8 years ago

Last modified 8 years ago

#33513 closed enhancement (fixed)

Add support for the 'lang' attribute in admin bar menu items.

Reported by: chouby's profile Chouby Owned by: swissspidy's profile swissspidy
Milestone: 4.5 Priority: normal
Severity: normal Version: 3.3
Component: Toolbar Keywords: has-patch commit
Focuses: accessibility Cc:

Description

The attributes for admin bar menu items allowed in Meta data are white listed:
'html', 'class', 'rel', onclick', 'target', 'title', 'tabindex'

I'd like to add the 'lang' attribute which is useful for accessibility in multilingual context.

Attachments (3)

33513.diff (1.7 KB) - added by Chouby 8 years ago.
33513.2.diff (1.6 KB) - added by leemon 8 years ago.
Added 'lang' and 'dir' attributes
33513.3.diff (1.6 KB) - added by leemon 8 years ago.
Second try at patch

Download all attachments as: .zip

Change History (20)

@Chouby
8 years ago

#1 @Chouby
8 years ago

  • Keywords has-patch added

#2 @morganestes
8 years ago

  • Summary changed from add support for the 'lang' attribute in admin bar menu items to Add support for the 'lang' attribute in admin bar menu items.

I think if we're adding lang to the list, we should also add dir along with it, since it complements lang from an internationalization standpoint, if not specifically an accessibility one.

This ticket was mentioned in Slack in #accessibility by rianrietveld. View the logs.


8 years ago

#4 follow-up: @rianrietveld
8 years ago

@Chouby
In this case the lang attribute is added to a link.
If you want to tell a screen reader what language to expect after selecting a link, you should use the attribute hreflang.
So in this case use hreflang.
W3C specs: http://www.w3.org/TR/html5/links.html#links-created-by-a-and-area-elements
But it's purely advisory, not a requirement.

The attribute lang is used to identify a language within an element, for example if you use a quote in another language, you will use:

<blockquote lang="nl">
Dikkertje Dap. Dikkertje Dap klom op de trap. 's Morgens vroeg om kwart over zeven. Om de giraf een klontje te geven.
<blockquote>

Then a screen reader can switch language/voice.
This is only used for more than 2 words, because the switching of a voice will take some time and that's irritating for small pieces of text.

@morganestes
Can you give an example where this is useful? dir is not an attribute of a I believe.

Last edited 8 years ago by rianrietveld (previous) (diff)

#5 @Chouby
8 years ago

As far as I understood, the lang and dir attributes are global and can be applied to a. That's not for the linked document but for the label of the link.

I wrote a multilingual plugin and would like to improve its accessibility. I am just starting in that domain so I have a lot to learn! In this plugin, I add the list of all languages in the admin bar and I use the native name. I understood that I should add the lang attribute for the language name beeing correctly pronounced.

Here is a piece of html code that I found easily on internet:

<a lang="ar" hreflang="ar" title="arabe" href="//ar.wikipedia.org/wiki/">العربية</a>

For my own usage, I don't need the hreflang attribute because the menu does not switch the admin language but activates a language filter (for the list of posts for example). But it could make sense to add more attributes such as hreflang or dir to the white list for other usages.

This is only used for more than 2 words, because the switching of a voice will take some time and that's irritating for small pieces of text.

I didn't know this rule, so in my case, that may be not useful. What do you think of the long list of available languages on all Wikipedia pages?

This ticket was mentioned in Slack in #accessibility by rianrietveld. View the logs.


8 years ago

#7 in reply to: ↑ 4 @morganestes
8 years ago

Replying to rianrietveld:

@morganestes
Can you give an example where this is useful? dir is not an attribute of a I believe.

dir is a global attribute, so it can be applied to a to indicate the direction of the language. If we're going to specify a language, it's a good idea to also allow the direction to be indicated.

This ticket was mentioned in Slack in #accessibility by rianrietveld. View the logs.


8 years ago

#9 follow-up: @afercia
8 years ago

Discussed a bit this ticket in the last a11y team Slack meeting, we agreed white listing lang and dir attributes doesn't harm and it's an improvement. Maybe some years ago switching language for just 1 or 2 words was discouraged because screen readers were very slow when doing the switch. Some screen readers didn't even support switching language. But maybe today screen readers are far better in that :)

#10 in reply to: ↑ 9 @morganestes
8 years ago

  • Keywords needs-patch added; has-patch removed

Replying to afercia:

Discussed a bit this ticket in the last a11y team Slack meeting, we agreed white listing lang and dir attributes doesn't harm and it's an improvement. Maybe some years ago switching language for just 1 or 2 words was discouraged because screen readers were very slow when doing the switch. Some screen readers didn't even support switching language. But maybe today screen readers are far better in that :)

Thanks for the update, I appreciate the a11y team taking a look.

The first patch was just for lang; @Chouby: can you update it to add dir to it?

@leemon
8 years ago

Added 'lang' and 'dir' attributes

#11 @Chouby
8 years ago

  • Keywords has-patch added; needs-patch removed

Too late. It's done yet :)

#12 @morganestes
8 years ago

  • Keywords needs-refresh added

The .2 patch doesn't apply cleanly for me with grunt patch.

@leemon
8 years ago

Second try at patch

#13 @morganestes
8 years ago

  • Keywords i18n-change commit added; needs-refresh removed

Patch applies cleanly and works to add the attributes via the meta array.

I discussed this with the Polyglots team at the 2015 Community Summit; they had some reservations about including it in core as opposed to introducing it via Babel. The concern is that it may conflict with work done by the Multilingual team, since it can be used to introduce multiple language menu items. After a quick check with @simonwheatley, that doesn't seem to be a blocking concern for this addition.

#14 @swissspidy
8 years ago

  • Owner set to swissspidy
  • Status changed from new to reviewing

#15 @ocean90
8 years ago

  • Keywords i18n-change removed

#16 @swissspidy
8 years ago

  • Resolution set to fixed
  • Status changed from reviewing to closed

In 35795:

Toolbar: Allow adding lang and dir attributes to toolbar items.

This is useful from a multilingual and accessibility perspective.

Props Chouby, leemon.
Fixes #33513.

#17 @netweb
8 years ago

  • Milestone changed from Awaiting Review to 4.5
Note: See TracTickets for help on using tickets.