Problem/Motivation
We wanna improve the UX (usability) to allow users to be warned when a block that is supposed to be shown is not going to do it. The feedback to the user will be done using warning messages
A language switcher block would not show any language if:
A. There is only 1 language configured (no languages to switch between).
B. There is no URL detection method configured (no method to switch languages via links).
This is correct. However users still enable the language switcher block and then get confused that it does not display. People assume it may be due to visibility settings, permissions, etc.
Proposed resolution
Add some helpful hint/text to the block config form that says why it would not show.
- (no) When user goes to the block layout and add the block, a warning message is showed in the modal window.
That way will warning the user before add the block - (yes) When the user goes to block layout, the block will not be able to be added. Could be showed with a tooltip or we could show a warning in the page or we could update the page description explaining this behavior.
That way warning the user from the beginning. - (yes) When user goes to the block layout and add a block, after submitting the configuration modal page, a warning message will be showed in the top of block layout page.
That way will warning the user after add it.

Remaining tasks
We need to add the patch the availability to show both message if both are happening. Right now, just show one of them.
| Task | Novice task? | Contributor instructions | Complete? |
|---|---|---|---|
| Create a patch | Instructions | ||
| Reroll the patch if it no longer applies. | Instructions | ||
| Update the issue summary | Instructions | Yes | |
| Update the issue summary noting if allowed during the beta | Instructions | ||
| Add automated tests | Instructions |
User interface changes
A new hint on why the block would not show.
API changes
No.
Beta phase evaluation
| Issue category | Task, because we are adding string messages in the UI to clarify the blocks behavior. |
|---|---|
| Issue priority | Normal, because we are improving the usability only in one small part, and not across many parts of core. |
| Prioritized changes | This issue improve the UX (usability). |
| Disruption | Not disruptive because we are changing LanguageBlock::constructor and LanguageBlock::create methods and its scope are just the language block, so will no affect to other classes, D8 beta sites or documentation (just the constructor comment block) |
| Comment | File | Size | Author |
|---|---|---|---|
| #92 | interdiff-2019511-79-92.txt | 4.08 KB | jacobsanford |
| #92 | explain_why_the-2019511-92.patch | 5.25 KB | jacobsanford |
| #79 | explain_why_the-2019511-79.patch | 5.23 KB | fran seva |
| #79 | interdiff_76-79.txt | 2.5 KB | fran seva |
| #76 | interdif_72-76.txt | 2.16 KB | fran seva |
Comments
Comment #1
e0ipsoComment #2
e0ipsoI don't think this is an issue anymore. Please, re-check.
Comment #3
e0ipsoI see now that if you have session enabled, then you also see the block.
Updating issue description.
Comment #4
e0ipsoFirst patch attempt.
Comment #5
e0ipsoComment #6
seutje commentedRemoving JavaScript tag, as this only touches PHP.
Adding usability review tag because the wording could probably use some work.
"You do not have any language detection method enabled that provide URL based detection. The language switcher module will not be shown."
Not a native speaker, but I'm fairly certain it should to be "provides".
Comment #7
e0ipsoCan someone provide a better wording?
Comment #7.0
e0ipsoAdd session detection to summary.
Comment #8
jhedstromPatch no longer applies.
Comment #9
rpayanmComment #10
jhedstromAs per #6, this should be provides.
Is there anywhere in the system we could link to in this text to ease the enabling of language detection?
Comment #11
rpayanmfixed :)
Comment #12
e0ipsoComment #13
jhedstromI think we should link language detection method to the configuration page at
admin/config/regional/language/detectionso people can see exactly where they need to go to make the change.Comment #14
gábor hojtsyNeeds tests. Additionally to that:
"No language detection method is enabled that would provide URL based detection. Therefore the language switcher block will not be shown."
Ie. module to block and instead of talking to the person, explaining the site config.
Comment #15
gábor hojtsyThis looks similar to #1082902: Improve language switcher usability?
Comment #16
gábor hojtsyComment #17
yesct commentedsince this is a minor task, would be good to document in the issue summary why this is allowed at this point in the beta. added link to instructions to do beta evaluation.
Comment #18
gábor hojtsyAs per https://www.drupal.org/contribute/core/beta-changes usability is prioritized. This is usability.
Comment #19
develcuy commentedComment #20
gábor hojtsy@develCuy: are you working on this one? The tag is supposed to be on issues someone is working/worked on.
Comment #21
develcuy commentedRemoved tag by mistake.
Comment #22
develcuy commentedRemoved tag by mistake.
Comment #23
kristen polThanks for the patch in #11.
I have confirmed that it does show up when configuring the block once placed in the region.
Should it also show up as soon as you click the block on the right side of the block layout page (e.g. /admin/structure/block/list/bartik) and before it is placed anywhere? It currently does not. I think this would be useful to see before it is placed so the user will know what to expect before placing it.
Comment #24
kristen polAlso, I realize the text is not correct. Needs to be updated per #14.
Comment #25
kristen polBased on the issue:
#1082902: Improve language switcher usability
I think the patch for this issue should differentiate between:
1) switch links aren't showing up because there is only one language
2) switch links aren't showing up because language negotiation settings
and then we can close:
#1082902: Improve language switcher usability
See comments here: https://www.drupal.org/node/1082902#comment-9524351
Comment #26
gábor hojtsyShorter description.
Comment #27
jlbellidoI'll work in this issue
Comment #28
jlbellidoI add a new patch rerolling the previous one (#11) because it didn't apply.
Comment #29
gábor hojtsy@jlbellido: thanks, the concerns raised from #14 onwards still apply, so needs work for those :)
Comment #30
gábor hojtsyUpdated summary, made much shorter.
Comment #31
jlbellidoI've updated #28 with the following:
* Updated message with #14 in case of no language method detection are enabled.
* As sugested in #25, I've introduced a different message when links are not showed because only 1 language is enabled and when no language method detection is enabled.
Tests still needed.
Comment #32
fran seva commentedHi @jlbellido!
Just a minor change in a comment.
The one line comments should end with "."
I have tested the UI and it's working and the code is good for me.
Comment #33
jlbellidoThanks @fran for review it. I add a new patch fixing it.
Comment #34
fran seva commentedFor me is RTBC.
Comment #35
fran seva commentedComment #36
fran seva commentedComment #37
alexpottThis is a block that uses a deriver - see Drupal\language\Plugin\Derivative\LanguageBlock. I think we can put this logic there and just not display the block in the list of available blocks if this is the case.
Comment #38
rodrigoaguilera@alexpott Then you have to explain why is not listed since people are going to look for the block and a message on the blocks page is too much.
Comment #39
fran seva commentedThinking in the user, I believe we should show that something is happening with that block but if we set the block not available the user will not know the reason, the user needs a feedback from UI.
I propose the following possibilities:
That way will warning the user before add the block
That way will warning the user after add it.
That way warning the user from the beginning.
Comment #40
fran seva commentedComment #41
fran seva commentedComment #42
fran seva commentedComment #43
fran seva commentedComment #44
fran seva commentedComment #45
fran seva commentedComment #46
fran seva commentedComment #47
fran seva commentedComment #48
fran seva commentedComment #49
yesct commentedI think we should show the block is available so it is discoverable. But I agree maybe we should not allow them to do something that will not have an effect.
I think that if they meet the conditions for the block to show, and then place it, and then later the conditions for having the block are not correct, we need to be careful and not remove settings they had on the block, but they should be warned about why the block disappeared. So:
I think we should try and do these two:
When the user goes to block layout, the block will not be able to be added. Could be showed with a tooltip or we could show a warning in the page or we could update the page description explaining this behavior.
That way warning the user from the beginning.
When user goes to the block layout and add a block, after submitting the configuration modal page, a warning message will be showed in the top of block layout page.
That way will warning the user after add it.
(I put them in the issue summary.)
---
Note @fran seva read https://www.drupal.org/core/issue-priority and put Major in the beta evaluations, but I do not think this is "important by community consensus". So I think normal is the right thing, because the effect is isolated to just the language switcher block and does not effect across many places in Core.
Comment #50
yesct commentedI know the code will change much if we go in the new direction, but I wanted to document feedback on the previous patch ...
That we should show both warnings if both conditions exist.
In the current code,
if there is only one language and a non url negotiation method, only the one language warning would be shown.
What should happen is they should be able to see both if both conditions are there.
---
Also removing medium, because I think this get more difficult if we go do one of the new proposals.
Comment #51
fran seva commentedWorking on it :)
Comment #52
fran seva commentedImplementing tests in #DrupalCampsEs2015
Comment #53
fran seva commentedAttach the test for the issue.
I'm implementing the changes that @YesCT proposed.
Also add the needs reroll tag and remove the Needs tests tag
Comment #54
fran seva commentedattach reroll.
Comment #56
gauravjeet commentedApplied this patch in #54 to a local branch, applied and auto-merged successfully. Removing Needs re-roll tag from the issue, also changed the name of patch to a standard name.
Comment #57
gauravjeet commentedchanged to RTBC
Comment #58
fran seva commentedHi!
The issue is not fixed, we need to apply the changes that @yesCT proposed.
Change the status to needs work
Comment #59
fran seva commentedI'm looking where I should implement the changes @YesCT proposed in #49 and I see that:
1. The user goes to block layout
1.1 Show a tooltip in the language Switcher: Reviewing the code I saw that the link and its attributes are added in BlockListBuilder::buildForm and I don't see the way to add it from LanguageBlock class. I think we should not change the BlockListBuilder:buildForm code, isn't it?
1.2 Change the page description:
This change have to be done in language.module in language_help, checking the route_name, block.admin_display and block.admin_display_theme, but my question is, Should this text be rendered just when language Switcher will not be able to be added? I think the text should be always present explaining how the language switcher should be configured to be added.
2. After add the block: Currently, the system is showing a message depending the user has just one language or URL detection is not enable. I think could be good show this messages (as you commented in #50) instead show a single message. I'm not sure if the message @YesCT refers in #49 are the same that #50.
Comment #60
yesct commentedI'm looking at this now.
While I was looking, noticed: #2500607: Some block categories are not translatable
Comment #61
yesct commentedok. I see the warning after adding the block, when returning to configure it. Seems fine.
I wanted to see the warning in the modal... before placing it, and thought that the warning didn't show at all, but it does! page just scrolls to where the change is in the block ordering, and so did not see the message at the top.
Comment #62
yesct commentedSo @fran seva and I talked in IRC
Here are some screenshots to hopefully clarify things.
with language module enabled (and only one language and/or url language detection disabled)
on admin/structure/block
there is a link to add a language switcher block
S1: I suggest we leave that UI alone there. (Not add any warning, and not take away the link to the language switcher block. Leaving the link there, gives people a way to discover the block and when we add the warning messages, how to make it show.)
After clicking on that link, a modal dialog popup appears to configure the block and with a button to save, which adds the block.
S2: I suggest that we have a warning in that modal.
S3: I suggest the warning contain a link to where a language can be added.
"Only one language is enabled. Therefore the language switcher block will not be shown."
S4: I suggest we do NOT disable the save block button to prevent adding the block. (Because, there is a scenario where the conditions are correct and it gets added, but then config changes and it wont show, but is still placed... and, it doesn't really hurt to place the block and then add more languages... and we are putting messages in so people will know to do that.)
After save, it goes to admin/structure/block/list/bartik?block-placement=languageswitcher
Then... instead of a drupal set message which puts something at the top of that block ordering page (which gets automatically scrolled right past. See #61)
S5: I suggest we put a warning in the row in the table for the language switcher block. (because it autoscrolls to that place anyway. and hopefully would be there not just after the save, but anytime returning to that blocks page.)
S6: I suggest we keep the warnings the patch adds to the configure page admin/structure/block/manage/languageswitcher
Comment #63
yesct commentedstrange, those files I added ... did not get listed on that comment.
here is the last one.
Comment #64
gauravjeet commented@YesCT,
I suggest we can leave the warning messages as is and give a link to where user can add a new language to the site, in the warning message itself.
Comment #65
gauravjeet commentedChanged issue status
Comment #66
fran seva commented@gauravjeet could you add an interdiff between your pach and the the #56?
If you need more info about it you can get it in [1]
[1] https://www.drupal.org/documentation/git/interdiff
Comment #67
gauravjeet commented@fran seva,
I made these changes only :
Comment #68
fran seva commented@gauravjeet, checking your last patch It seems that there are more changes and seems to be related to other issue (I think).
For example, I see the patch add this change
why?
In other hand, every time a patch is post it, have to be posted an interdiff file. In [1] you can get how create the file
The reason for it, is that the reviewer could check just the last changes and not all the changes in a patch.
[1]https://www.drupal.org/documentation/git/interdiff
Comment #69
fran seva commentedComment #70
deepakaryan1988Removing sprint weekend tag and other irrelevant tags!!
As suggested by @YesCT
Comment #71
deepakaryan1988Sorry, these issues were actually worked on during the 2015 Global Sprint
Weekend https://groups.drupal.org/node/447258
Comment #72
fran seva commented@gauravjeet I have cleaned your patch because there was changes not related to the issue (the clean patch with your proposal is explain_why_the-2019511-72.patch. I also attach the interdiff with the last patch (interdiff-54-72).
Reviewing the interdiff I see your proposal is not what @YesCT describe in the issue and its what is supposed to do but I think could be a good idea show the link to configure it.
I also see that the patch is not including the tests and should be. As conclusion the pending task are:
- Improve tests
- implement @YesCT proposal
- add test to main patch.
I have hidden the wrong patches and I have added the clean version.
Comment #73
fran seva commentedups...the status
Comment #74
fran seva commentedComment #75
fran seva commentedComment #76
fran seva commentedAttach patch with tests and interdiff.
The patch should be red
Comment #77
jhedstromThis file should be removed from the patch.
The call to the
t('Language list')function should be replaced by$this->t().Small nit: there needs to be a space between
)and?, andtrueandfalseshould be upper cased.Also, instead of manually calling the
__toString()magic method, casting to a string might be more clear:(string) $warning === '...'Comment #79
fran seva commented@jhedstrom thanks for review.
Attach the patch with the fixes.
I'm working in @YesCT proposal.
Comment #81
fran seva commented@YesCT I'm having some problems to show the message in the modal form.
Currently the code is using drupal_set_message in LanguageBlock::blockForm to render the message but this happens after submit the form and that is not what we want.
I'm not sure how do it because I see problems in all solutions I think:
1. in LanguageBlock::blockForm add an form item to show the message. This is not good because we are not using the drupal way to show messages. AFAIK we wanna show the drupal_set_message style but we could show the message just as a text without the drupal_set_message.
2. I think the message should be "done" from language module, which is the module that generate the block. But if we wanna show the message with drupal_set_message we should do before generate the modal form. make that sense?
3. Another option could be add the message using JS. The JS file could be in language module and when the form where loaded will check the number of languages and the language-url configuration. Is this the way to do it?
Are there in D8 a way to show messages in modal forms? I'm looking in code a similar use case.
Comment #85
gagarine commentedNo more work on that? This kind of features provide a lot of value for users.
Comment #86
gagarine commentedComment #88
bleg commentedThere is another condition that must be correct to show the block that took me ages to find!
"Interface text language selected for page" must be set on /admin/config/regional/content-language
I would also recommend this be the default as I think it would be the normal setup.
Comment #92
jacobsanford@fran seva's patch in #79 no longer applied to 8.9.x. A reroll with no further modifications is attached.