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
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:
Comment | File | Size | Author |
---|---|---|---|
#70 | 2547639-70_Many_links_called_Menu_in_Bartik.patch | 1.01 KB | mgifford |
#62 | spainish.jpg | 46.99 KB | dcrocks |
#62 | interdiff-2547639-55-62.txt | 1.31 KB | dcrocks |
#62 | 2547639-62_Many_links_called_Menu_in_Bartik.patch | 1.01 KB | dcrocks |
#60 | spanish.jpg | 49.37 KB | dcrocks |
Comments
Comment #2
dawehner@mgifford
Do you mind explaining a suggestion what exactly should be done? If written properly, I hope this could be a novice task.
Comment #3
mgifford@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.Comment #4
dcrocks CreditAttribution: dcrocks as a volunteer commentedWould this be the right approach?
Comment #5
dcrocks CreditAttribution: dcrocks as a volunteer commentedThis 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.
Comment #6
dcrocks CreditAttribution: dcrocks as a volunteer commentedThis is what it might look like if the expansion icon was on the left side.
Comment #7
mgiffordThat's way better. Can we just append the Show/Hide like:
I think that would do it.
Comment #8
Pravin Ajaaz CreditAttribution: Pravin Ajaaz as a volunteer and at Ameex-Drupal Geeks commentedPatch based on mgifford's suggestion.
Comment #10
dcrocks CreditAttribution: dcrocks as a volunteer commentedI'm not sure if it couldn't be simpler.
Comment #11
mgiffordLooks great to me. Thanks @dcrocks
Comment #12
alexpottDon't we have a problem with capitalisation... eg. "Hide Main navigation" and "Show Main navigation"?
Comment #13
dcrocks CreditAttribution: dcrocks as a volunteer commented'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?
Comment #14
mgifford@alexpott it won't matter for screen readers, which is who this is targeted at largely, right? Pretty much nobody else will see it.
Comment #15
dcrocks CreditAttribution: dcrocks as a volunteer commentedThis is what it looks like currently with 2 menus in the primary menu region. It really should get in before RC.
Comment #16
dcrocks CreditAttribution: dcrocks as a volunteer commentedHere is a patch that addresses case issue
Comment #17
mgiffordComment #18
mgiffordComment #19
mgiffordThe 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.
Comment #20
mgiffordComment #21
mgiffordComment #22
Wim LeersNice!
Comment #25
mgiffordThe bot seems to be broken, but this does need a re-roll.
Comment #26
dcrocks CreditAttribution: dcrocks as a volunteer commentedThis still applies without error. Why the reroll?
Comment #27
mgiffordSorry, I think SimplyTest.me gave me a failed load the last time I tried.
Comment #29
dcrocks CreditAttribution: dcrocks as a volunteer commentedAs 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.
Comment #30
Wim LeersShouldn't this use
trans
? i.e. something like:The current patch simply hardcodes a translate verb followed by a translatable menu name. Not every language has this word order.
Comment #31
Gábor HojtsyYup, 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.
Comment #32
mgiffordOk, I think this will cover it. @Gábor Hojtsy - is this going to be sufficient for the label?
Comment #34
Gábor HojtsyI don't think that is how you represent variables with {%trans%}. See examples in https://www.drupal.org/node/2047135.
Comment #35
mgiffordThanks for the example... This looks closer:
Comment #36
dcrocks CreditAttribution: dcrocks as a volunteer commented{% 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.
Comment #37
Gábor Hojtsy@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.
Comment #38
mgiffordBots like it. What else do we need to do to mark this patch RTBC? The output is just like #19.
Thanks @Gábor Hojtsy!
Comment #39
dcrocks CreditAttribution: dcrocks as a volunteer commentedI 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.
Comment #40
dcrocks CreditAttribution: dcrocks as a volunteer commentedSo 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?
Comment #41
dcrocks CreditAttribution: dcrocks as a volunteer commentedSo 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.
Comment #42
Gábor Hojtsy@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.
Comment #43
Gábor HojtsyI 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).
Comment #44
Gábor HojtsyThe 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.
Comment #45
dcrocks CreditAttribution: dcrocks as a volunteer commented@Hojtsy Filters don't work inside a {% trans %}{% endtrans %} so you have to do that outside of there, eg,
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.
Comment #46
Gábor Hojtsy@dcrocks: Drupal has been doing well with variable placeholders in translatable strings for a decade, so you can just reformat:
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.
Comment #47
dcrocks CreditAttribution: dcrocks as a volunteer commented@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.
Comment #48
Gábor Hojtsy@dcrocks: I don't get what the problem is. How do all the other % trans % blocks work in core with placeholders then? :)
Comment #49
dcrocks CreditAttribution: dcrocks as a volunteer commentedGood 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'
Comment #50
Gábor Hojtsy@dcrocks: did you go and translate "Show @menu_label" as well in your interface translation UI?
Comment #51
dcrocks CreditAttribution: dcrocks as a volunteer commentedNo. Is that the trick?
Comment #52
Gábor Hojtsy@dcrocks: how would Drupal know the translation of that brand new string that never was part of Drupal 8 but added with this patch?
Comment #53
dcrocks CreditAttribution: dcrocks as a volunteer commentedOk, I'll look up the documentation on that. Have to go now, respond in a few hours.
Comment #54
dcrocks CreditAttribution: dcrocks as a volunteer commentedSorry, 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?
Comment #55
dcrocks CreditAttribution: dcrocks as a volunteer commentedHere is a the revised patch. I tested in english and spanish. Someone else should check, hopefully also in a RTL language.
Comment #56
Gábor Hojtsy@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:
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?
Comment #57
dcrocks CreditAttribution: dcrocks as a volunteer commentedFair 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?
Comment #58
Gábor HojtsySounds good to me.
Comment #59
dcrocks CreditAttribution: dcrocks as a volunteer commentedWe will need input from others before we can go forward.
Comment #60
dcrocks CreditAttribution: dcrocks as a volunteer commentedHere is an example where I used a special character.
Comment #61
Pravin Ajaaz CreditAttribution: Pravin Ajaaz as a volunteer and at Young Globes commentedComment #62
dcrocks CreditAttribution: dcrocks as a volunteer commentedThis 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'.
Comment #63
dcrocks CreditAttribution: dcrocks as a volunteer commentedsigh
Comment #65
mgiffordThis 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?
Comment #66
Gábor HojtsyIt 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.
Comment #67
dcrocks CreditAttribution: dcrocks as a volunteer commentedI 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:
'⇒' '⇾' '∷' '↦' '⇛' '⇥' '∴' '∷' '≔' '≫' '⊳' '⊸' '⋙' '⌂' '▸' '⟶' '⟹' '⩸' '⧁'
Comment #68
dcrocks CreditAttribution: dcrocks as a volunteer commentedFor example, I could enter
'⟹'
as '⟶, which would be helpful for the blind.
Comment #69
mgiffordIn that case, why not use '—'
—
.It would make sense that a screen reader would read something like the '⟹'
⟶
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.
Comment #70
mgiffordJust a re-roll with —
Comment #71
Gábor HojtsyMakes sense :)
Comment #73
dcrocks CreditAttribution: dcrocks as a volunteer commentedTime to get this done. @mgifford Good research.
Comment #74
xjmComment #75
mgiffordThat's a better title, thanks!
Comment #78
xjm@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.
Comment #80
xjm