In talking to Bart Simons on Twitter, he raised the issue that there were multiple links called "Menu" with no further context http://twitter.com/simonsbart/status/629650324278648833

Breaks WCAG 2.0 A:
2.4.4 Link Purpose (In Context): The purpose of each link can be determined from the link text alone or from the link text together with its programmatically determined link context, except where the purpose of the link would be ambiguous to users in general. (Level A)

Why this should be an RC target

.

When someone begins evaluating Drupal for accessibility, one of the first things they will run into is these duplicate links. Not being able to determine Menu items apart will be confusing to blind users who are first starting to use Drupal.

RC phase evaluation

Reference: https://www.drupal.org/core/d8-allowed-changes
Issue category Bug that breaks basic navigation for screen readers.
Issue priority Major for screen readers, but normal.
Allowed in RC Because it is a non-disruptive accessibility bug.
Needed in RC Because it's a highly visible error as it appears on default installation home page.
Disruption: Fixes a bug, blocks a contributed project, or should be backported to Drupal 7 Not disruptive.

This comes from core/themes/bartik/templates/block--system-menu-block.html.twig

It doesn't seem to appear in the other block--system-menu-block.html.twig files.

    <a class="menu-toggle" href="#{{ show_anchor }}">{{ 'Menu'|t }}</a>
    <a class="menu-toggle menu-toggle--hide" href="#{{ hide_anchor }}">{{ 'Menu'|t }}</a>

It is important to add information about the menu & what it does.

Proposed Output

So on the first page after loading a site, it would be important to have the following output HTML:

    <a class="menu-toggle" href="#show-block-bartik-account-menu">Show user account menu</a>
    <a class="menu-toggle menu-toggle--hide" href="#hide-block-bartik-account-menu">Hide user account menu</a>
    <a class="menu-toggle" href="#show-block-bartik-main-menu">Show main navigation menu</a>
    <a class="menu-toggle menu-toggle--hide" href="#hide-block-bartik-main-menu">Hide main navigation menu</a>
    <a class="menu-toggle" href="#show-block-bartik-tools">Show tools menu</a>
    <a class="menu-toggle menu-toggle--hide" href="#hide-block-bartik-tools">Hide tools menu</a>
    <a class="menu-toggle" href="#show-block-bartik-footer">Show footer menu</a>
    <a class="menu-toggle menu-toggle--hide" href="#hide-block-bartik-footer">Hide footer menu</a>

See:

Before/after screenshots

CommentFileSizeAuthor
#70 2547639-70_Many_links_called_Menu_in_Bartik.patch1.01 KBmgifford
#62 spainish.jpg46.99 KBdcrocks
#62 interdiff-2547639-55-62.txt1.31 KBdcrocks
#62 2547639-62_Many_links_called_Menu_in_Bartik.patch1.01 KBdcrocks
#60 spanish.jpg49.37 KBdcrocks
#55 interdiff-2547639-35-55.txt1.31 KBdcrocks
#55 2547639-55_Many_links_called_Menu_in_Bartik.patch1.21 KBdcrocks
#43 Welcome to drupal 8.0.x | drupal 8.0.x 2015-11-09 09-07-52.png90.08 KBGábor Hojtsy
#41 spanishtest2.jpg48.46 KBdcrocks
#39 spanishtest.jpg45.7 KBdcrocks
#39 spanishmenu.jpg107.99 KBdcrocks
#39 spanish.jpg45.62 KBdcrocks
#39 english.jpg42.7 KBdcrocks
#35 2547639-35_Many_links_called_Menu_in_Bartik.patch1 KBmgifford
#32 2547639-32_Many_links_called_Menu_in_Bartik.patch1.01 KBmgifford
#29 2547639-29_Many_links_called_Menu_in_Bartik.patch994 bytesdcrocks
#19 comparison-without-confusing-menu-links.png176.66 KBmgifford
#16 2menu.jpg50.14 KBdcrocks
#16 interdiff-2547639-10-16.txt1.02 KBdcrocks
#16 2547639-16_Many_links_called_Menu_in_Bartik.patch994 bytesdcrocks
#15 2menu.jpg48.4 KBdcrocks
#10 hidemenu.jpg51.53 KBdcrocks
#10 showmenu.jpg46.84 KBdcrocks
#10 interdiff-2547639-4-10.txt1004 bytesdcrocks
#10 2547639-10_Many_links_called_Menu_in_Bartik.patch978 bytesdcrocks
#8 many_links_called-2547639-8.patch1.04 KBPravin Ajaaz
#6 leftside.jpg51.17 KBdcrocks
#5 multiplemenus.jpg57.17 KBdcrocks
#4 unexpanded.jpg42.23 KBdcrocks
#4 expanded.jpg52.65 KBdcrocks
#4 2547639-4_Many_links_called_Menu_in_Bartik.patch958 bytesdcrocks
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mgifford created an issue. See original summary.

dawehner’s picture

@mgifford

Do you mind explaining a suggestion what exactly should be done? If written properly, I hope this could be a novice task.

mgifford’s picture

Issue summary: View changes

@dawehner I outlined what I hoped the HTML output should be. Right now it simply identifies as a {{ 'Menu'|t }} which just isn't enough context.

dcrocks’s picture

Status: Active » Needs review
FileSize
958 bytes
52.65 KB
42.23 KB

Would this be the right approach?

dcrocks’s picture

FileSize
57.17 KB

This is what it would look like if there were multiple menus in the primary menu region. A question: wouldn't it be better if the expansion icon was on the left instead of the right? That would make it consistent with the toolbar menu. And more intuitive I think.

dcrocks’s picture

FileSize
51.17 KB

This is what it might look like if the expansion icon was on the left side.

mgifford’s picture

That's way better. Can we just append the Show/Hide like:

+    <a class="menu-toggle" href="#{{ show_anchor }}">{% 'Show @configuration.label'|t({'@configuration.label': configuration.label}) %}</a>
+    <a class="menu-toggle menu-toggle--hide" href="#{{ hide_anchor }}">{% 'Hide @configuration.label'|t({'@configuration.label': configuration.label}) %}</a>

I think that would do it.

Pravin Ajaaz’s picture

Patch based on mgifford's suggestion.

Status: Needs review » Needs work

The last submitted patch, 8: many_links_called-2547639-8.patch, failed testing.

dcrocks’s picture

Status: Needs work » Needs review
FileSize
978 bytes
1004 bytes
46.84 KB
51.53 KB

I'm not sure if it couldn't be simpler.

mgifford’s picture

Status: Needs review » Reviewed & tested by the community

Looks great to me. Thanks @dcrocks

alexpott’s picture

Status: Reviewed & tested by the community » Needs review

Don't we have a problem with capitalisation... eg. "Hide Main navigation" and "Show Main navigation"?

dcrocks’s picture

'Main navigation' is generated from config and is the way the menu name is displayed other places, eg., admin/structures/block. But it is easy to change. Who would decide?

mgifford’s picture

@alexpott it won't matter for screen readers, which is who this is targeted at largely, right? Pretty much nobody else will see it.

dcrocks’s picture

FileSize
48.4 KB

This is what it looks like currently with 2 menus in the primary menu region. It really should get in before RC.

dcrocks’s picture

Here is a patch that addresses case issue

mgifford’s picture

Issue summary: View changes
mgifford’s picture

Issue summary: View changes
mgifford’s picture

Issue summary: View changes
Status: Needs review » Reviewed & tested by the community
FileSize
176.66 KB

The capitalization issue doesn't matter since this is only displayed for screen readers. I'm hoping with the screenshot & RC phase evaluation this is sufficient for the RC phase. It's a simple change in a twig template.

Comparison of before-after screenshots

mgifford’s picture

Issue summary: View changes
Issue tags: +rc target triage
mgifford’s picture

Issue summary: View changes
Wim Leers’s picture

Issue tags: +Quickfix

Nice!

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 16: 2547639-16_Many_links_called_Menu_in_Bartik.patch, failed testing.

mgifford’s picture

Issue tags: +Needs reroll

The bot seems to be broken, but this does need a re-roll.

dcrocks’s picture

This still applies without error. Why the reroll?

mgifford’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll

Sorry, I think SimplyTest.me gave me a failed load the last time I tried.

Status: Reviewed & tested by the community » Needs work

The last submitted patch, 16: 2547639-16_Many_links_called_Menu_in_Bartik.patch, failed testing.

dcrocks’s picture

Status: Needs work » Needs review
FileSize
994 bytes

As far as I can tell the test never finished and I can't see how to resubmit it. So here is the same patch again. The diff was 0.

Wim Leers’s picture

Status: Needs review » Needs work

Shouldn't this use trans? i.e. something like:

{% trans %}Book outline for {{ book.title }}{% endtrans %}

The current patch simply hardcodes a translate verb followed by a translatable menu name. Not every language has this word order.

Gábor Hojtsy’s picture

Yup, the word order should be modifiable. Also, why do we t()-ed the label in twig? Is it coming from a loaded config object? That should already be loaded in the right language unless you explicitly loaded in its original form. So should not be t()-ed. Anyway, configuration should not be t()-ed in general.

mgifford’s picture

Status: Needs work » Needs review
FileSize
1.01 KB

Ok, I think this will cover it. @Gábor Hojtsy - is this going to be sufficient for the label?

+    <a class="menu-toggle" href="#{{ show_anchor }}">{% trans %}{{ 'Show ' ~ configuration.label|lower }}{% endtrans %}</a>
+    <a class="menu-toggle menu-toggle--hide" href="#{{ hide_anchor }}">{% trans %}{{ 'Hide ' ~ configuration.label|lower }}{% endtrans %}</a>

Status: Needs review » Needs work

The last submitted patch, 32: 2547639-32_Many_links_called_Menu_in_Bartik.patch, failed testing.

Gábor Hojtsy’s picture

I don't think that is how you represent variables with {%trans%}. See examples in https://www.drupal.org/node/2047135.

mgifford’s picture

Status: Needs work » Needs review
FileSize
1 KB

Thanks for the example... This looks closer:

+    <a class="menu-toggle" href="#{{ show_anchor }}">{% trans %} Show {{ configuration.label|lower }}{% endtrans %}</a>
+    <a class="menu-toggle menu-toggle--hide" href="#{{ hide_anchor }}">{% trans %} Hide {{ configuration.label|lower }}{% endtrans %}</a>
dcrocks’s picture

{% trans %} is part of the Twig "i18n" extension, which also requires the GETTEXT extension installed on PHP. I don't see that extension installed in Drupal, and gettext is not the default on mac OS X. So that seems to mean that we have to use the t filter.

Gábor Hojtsy’s picture

@dcrocks: Drupal uses the same trans tag but implements it our own way to integrate with Drupal. No need for getting or anything else. It works the same as the t filter.

mgifford’s picture

Bots like it. What else do we need to do to mark this patch RTBC? The output is just like #19.

Thanks @Gábor Hojtsy!

dcrocks’s picture

FileSize
42.7 KB
45.62 KB
107.99 KB
45.7 KB

I created a Spanish version of drupal from a current clone of 8.0.0 and it doesn't appear to be working. I've attached images to show the English and Spanish version of the sites. I also show an image of the structure/menu form which shows that the menu titles(and machine names) for the main and account menus aren't translated while their menu link titles are. The menu titles of all other menus are translated but their machine names aren't. Also note that the lower case filter doesn't seem to apply.
While experimenting with the code I noticed if I separate the 2 parts of the translated string to separate calls to (% trans %} the literal string(show/hide) will be translated but the menu label is not.

<a class="menu-toggle" href="#{{ show_anchor }}">{% trans %} Show {% endtrans %}
    {% trans %} {{ configuration.label|lower }} {% endtrans %}</a>
dcrocks’s picture

So I don't know how translation is actually done in drupal. Is it a table lookup for single words and phrases, or is each word in a phrase translated against a dictionary separately?

dcrocks’s picture

FileSize
48.46 KB

So the issue is that not all menu titles have translations. 'Main navigation' and 'Account' fall into this category. In particular Show or Hide concatenated onto a menu title will most likely not have a translation. But some menus titles are already translated and don't need translation in this template. So I modified the code to:
<a class="menu-toggle" href="#{{ show_anchor }}">{% trans %} Show {% endtrans %} {{ configuration.label|lower }}</a>
I added a menu with a translated title to the primary menu region and the attached image shows it works as expected. But this will not work for RTL languages. One step at a time.

Gábor Hojtsy’s picture

@dcrocks that a string that this issue would add does not already have a translation for some language would not surprise me. The issue proposes to add the new source string, so just natural :) The new source string should however show up in the interface translation UI and let you translate it. Separating the string to translate a word and a placeholder does not allow for swapping the order where a language translation requires "show" to come after the name of the thing. Not all languages use the same word order.

Gábor Hojtsy’s picture

Issue summary: View changes
Status: Needs review » Needs work
FileSize
90.08 KB

I test-drove this on simplytest.me. The strings appear as source strings "Hide @configuration.label" and "Show @configuration.label". The Hungarian translation would require the word to go after the label, so "@configuration.label megjelenítése" for example. Translating to that of course worked with interface translation. Basically two things:

1. The lowercasing does not seem to actually work.
2. If the order of the words is swapped (as required by the Hungarian translation), then the "sentence" starts off with a lowercase character, is that desired?
3. Do we use dotted variable names elsewhere? I am not sure. Twig can IMHO reassign that value to a simpler variable name, so the placeholder for translation is simpler.

Translated both the string and the menu name for this screenshot (neither is translated in the Hungarian translation either ATM).

Gábor Hojtsy’s picture

The parser behind localize.drupal.org does not seem to be expecting dotted variable names. See #2610436: Twig templates incorrectly use % trans % with arbitrary filters for an issue around that.

dcrocks’s picture

@Hojtsy Filters don't work inside a {% trans %}{% endtrans %} so you have to do that outside of there, eg,

 {% set menu_show_label = 'Show ' ~ configuration.label|lower %}
 {% set menu_hide_label = 'Hide ' ~ configuration.label|lower %}
...
...
...
<a class="menu-toggle" href="#{{ show_anchor }}">{% trans %} {{ menu_show_label }} {% endtrans %}</a>
...

But you would still have to manually provide a translation for the complete string. And also that clearly has problems with RTL language display. I did spend some time to see if there was a 'ltr!rtl' variable available to use code logic to build the string properly but if you have to hand translate each string manually it doesn't seem like much point.
This means that in all cases an admin would have to provide translated strings for this display of the menu for their site.

ps. I don't speak Spanish, I just chose it because I thought it would be fairly easy to navigate the site.

Gábor Hojtsy’s picture

@dcrocks: Drupal has been doing well with variable placeholders in translatable strings for a decade, so you can just reformat:

{% set menu_label = configuration.label|lower %}
<a class="menu-toggle" href="#{{ show_anchor }}">{% trans %} Show {{ menu_label }} {% endtrans %}</a>

Which will end up as "Show @menu_label" for translation. All built-in menu labels are translated separate from the "Show @menu_label" string on localize.drupal.org and Drupal combines them to form the resulting string. Otherwise how could we do "Dear @username" and such? We cannot expect the site owner to translate the string for each username.

dcrocks’s picture

@hojtsy {%trans %} resolves the entire string before it tries to translate. You should try your method with menus that don't already have a translation.

Gábor Hojtsy’s picture

@dcrocks: I don't get what the problem is. How do all the other % trans % blocks work in core with placeholders then? :)

dcrocks’s picture

Good question. It didn't work for me. I used <a class="menu-toggle" href="#{{ show_anchor }}">{% trans %} Show {{ menu_label }} {% endtrans %}</a>
an it didn't work. I got 'Show herramientas'

Gábor Hojtsy’s picture

@dcrocks: did you go and translate "Show @menu_label" as well in your interface translation UI?

dcrocks’s picture

No. Is that the trick?

Gábor Hojtsy’s picture

@dcrocks: how would Drupal know the translation of that brand new string that never was part of Drupal 8 but added with this patch?

dcrocks’s picture

Ok, I'll look up the documentation on that. Have to go now, respond in a few hours.

dcrocks’s picture

Sorry, server update bollixed my system. Ok, I see how to add that definition through the language interface. But still, doesn't that mean I'll have to add that definition each time I install drupal in a different language?

dcrocks’s picture

Here is a the revised patch. I tested in english and spanish. Someone else should check, hopefully also in a RTL language.

Gábor Hojtsy’s picture

@dcrocks: re #54, no, if we would only ever add "new" strings which are already translatable / translated, then we could never add new strings. Once this patch lands, the next release will make the string available on localize.drupal.org for translation and teams will be able to translate it, making it available on your sites later on as already translated.

Reviewing the patch again:

+++ b/core/themes/bartik/templates/block--system-menu-block.html.twig
@@ -9,13 +9,14 @@
+{% set menu_label = configuration.label|lower %}

Once again I am wondering if we want to lowercase this on the expense of it coming out as an all lowercase "sentence" for those who need to swap the verb with the menu name (such as in Hungarian). Is the lowercasing of more value for the languages where the order of the verb does not need to be swapped?

dcrocks’s picture

Fair argument. In English eyes it is the correct grammatical representation. But perhaps we could add some markup that would allow for two capitalization's in the phrase. Possibly Show - Main menu?

Gábor Hojtsy’s picture

Status: Needs review » Needs work

Sounds good to me.

dcrocks’s picture

We will need input from others before we can go forward.

dcrocks’s picture

FileSize
49.37 KB

Here is an example where I used a special character.

Pravin Ajaaz’s picture

dcrocks’s picture

This patch eliminates lower casing the menu label in deference to languages that may not have the same capitalization rules as english. It also adds a double arrow separator to imply '(Show/Hide) This'.

dcrocks’s picture

Status: Needs work » Needs review

sigh

The last submitted patch, 32: 2547639-32_Many_links_called_Menu_in_Bartik.patch, failed testing.

mgifford’s picture

This should be just fine. I'm not certain how http://www.codetable.net/decimal/8658 will be read by all screen readers, but the most important thing is the text.

@Gábor Hojtsy Any other i18n concerns? We good to mark this RTBC?

Gábor Hojtsy’s picture

It looks fine from a translatability perspective. I am not sure about the use of the special char, but nothing particularly against it. Looks good for translation.

dcrocks’s picture

I can use named entities instead of the numeric entities to make it more understandable for the blind, assuming they understand english. I also have looked at other characters that might be more meaningful(visually) but I can't find much that matches the drupal icon set:

'⇒' '⇾' '∷' '↦' '⇛' '⇥' '∴' '∷' '≔' '≫' '⊳' '⊸' '⋙' '⌂' '▸' '⟶' '⟹' '⩸' '⧁'

dcrocks’s picture

For example, I could enter '⟹' as '&longrightarrow;, which would be helpful for the blind.

mgifford’s picture

In that case, why not use '—' &mdash;.

It would make sense that a screen reader would read something like the '⟹' &longrightarrow; but it doesn't seem to work according to Jason Kiss or my testing with VoiceOver.

Lots of ways to introduce logical breaks though that don't convey a logical meaning that doesn't exist.

mgifford’s picture

Gábor Hojtsy’s picture

Status: Needs review » Reviewed & tested by the community

Makes sense :)

The last submitted patch, 32: 2547639-32_Many_links_called_Menu_in_Bartik.patch, failed testing.

dcrocks’s picture

Time to get this done. @mgifford Good research.

xjm’s picture

Title: Many links called "Menu" in Bartik » Rename ambiguous "Menu" toggle in Bartik for accessibility
mgifford’s picture

That's a better title, thanks!

  • xjm committed 974e340 on
    Issue #2547639 by dcrocks, mgifford, Pravin Ajaaz, Gábor Hojtsy, Wim...

  • xjm committed a71771f on
    Issue #2547639 by dcrocks, mgifford, Pravin Ajaaz, Gábor Hojtsy, Wim...
xjm’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +String change in 8.0.1

@catch, @alexpott, and I discussed this issue. The patch includes the addition of two strings and changes the translated text on a user-facing link. The affected text is only for accessibility purposes (screen readers, etc.), but is also almost useless for that usecase in HEAD. Changing it does not affect the display of the site otherwise. The changed string also includes an already-translated label, so even for screen reader users on non-English sites, there is some context for the changed text until translations are updated.

For these reasons, we decided it would be best to commit this to 8.0.x for the next patch release despite the disruption for translations.

Thanks for the issue report, fix, and review for translatability! Committed and pushed to 8.1.x and cherry-picked to 8.0.x.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

xjm’s picture

Issue tags: -rc target triage