Download & Extend

Theme language switcher for seven theme

Project:Drupal core
Version:8.x-dev
Component:language.module
Category:task
Priority:normal
Assigned:Unassigned
Status:needs work
Issue tags:#SprintWeekend, D8MI, frontend, language-config, language-content, medium, Usability

Issue Summary

Problem/Motivation

With the introduction of the form language concept in #1498874: Provide language awareness to entity forms (introduce the form language concept), we will need a language switcher allowing to choose the form active language.

Proposed resolution

Agreement that a drop button as in #7

Remaining tasks

Done: mock ups.
Done: ui element chosen. (We need to figure out if this can be a regular language switcher block or if it will be a UI elelment placed inside the form itself.)
Done: initial implementation (proceeded since form language landed #1498874: Provide language awareness to entity forms (introduce the form language concept)).

Todo:

User interface changes

Before: #5
Proposed: #7

API changes

todo: clarify if there would be api changes. (API changes/additions that would affect module, install profile, and theme developers, including examples of before/after code if appropriate)

Related

#1874102: Rename language switcher blocks (to differentiate content and UI)

Comments

#1

tagging

#2

So I guess #1498874: Provide language awareness to entity forms (introduce the form language concept) should go first? :) Or would you like to get people going with making up ideas about this?

#3

Well, surely some UX discussion could help here. However the implementation will have to wait for form language to land...

#4

Title:Introduce a form language switcher» Theme language switcher for seven theme
Component:forms system» language.module

Retitling issue for updated thinking, that it should just be the language switcher block reused. Needs to be themed for Seven since it looks bad as-is.

#5

Assigned to:Anonymous» ytsurk

i would work on this,

language switcher block in seven

right now there is a list displayed, what would you imagine instead .. ?
there are also a lot of modules around that block. (dropdown, flags etc.)

could be some show/hide functionality for the list, useful if very big ..
also there are two blocks now (UI text / content) - probably they should have a different feeling

#6

here again the broken screenshot:

language switcher block in seven

AttachmentSizeStatusTest resultOperations
2012-11-05 03.22.21 pm.png9.44 KBIgnored: Check issue status.NoneNone

#7

Assigned to:ytsurk» Anonymous

This is first suggestion (UX improvements).

Theme language switcher for seven theme suggestion - A

Theme language switcher for seven theme suggestion - B

So, what you think?

AttachmentSizeStatusTest resultOperations
1498880-7-a.png43.81 KBIgnored: Check issue status.NoneNone
1498880-7-b.png45.57 KBIgnored: Check issue status.NoneNone

#8

i like the approach; reuse of the standard - dropbutton (at least looks like it) - this will even be cross-theme !

maybe the title could be placed before, inlined.

#9

Issue tags:+Usability

Wow, it is amazingly fascinating how close is this to Bojhan's suggestion from http://drupal.org/node/1282018#comment-6120798, amazing. Will let him know to look at this one :)

#10

Also, why would you use lowercase at the start? Just to satisfy the general use of this dropdown link link? Languages are uppercase...

#11

Ignore the characters case, It was quick "design in browser" thing.

#12

Good. Drop button seems to be the right way to go here, since the action of switching will be done right on picking (there is no additional save or switch button).

I'll update the issue summary.
If someone wants to code this up, go ahead and assign the issue to yourself. :) [edit: @plach do you think this could be picked up by someone? I am not sure what level of difficulty it is but it seemed like it might be not too hard for someone to come into.]

#13

Maybe I can do it.
Just curious, do you consider to do it with:

  • Default block for switching language, just put that block in some region and adjust css/theme
  • Default block render in theme directly (without region), adjust css
  • Create new theme function (or other custom coding) to render language links as dropbutton-widget

What are preferences here? This is what determines this task hard or easy.

#14

@Dragan Eror: I'd add a theme function override for the language list in the Seven theme (it does not currently have its own theme I think although it might in fact have). If/when blocks as plugins are committed, we could have instance settings on blocks, so we can set a block instance in the frontend theme to be a classic HTML list display and on the backend as a dropbutton.

#15

I think this is the issue Gabor refers to: #1535868: Change notice: Convert all blocks into plugins

We could get a start on this without worrying about that, or use one of the recent patches there, and do something on top of that.

I'm guessing this is a good issue for someone to jump into, but that it might be challenging (not novice).

The desired UI is agreed on, any initial patch is good at spurring on progress.

I'll update the issue summary remaining tasks.

#16

#17

Assigned to:Anonymous» jibran

I am going to work on this one. Going to create a language switcher block with drop button language list.

#18

Assigned to:jibran» Gaelan

I'm working on this. Here are the options I can see:

  • Add a new element (I'll call it a popbutton)
  • Just CSS it
  • Use the existing dropbutton element

I personally prefer the popbutton element because I think we need CSS, and I think the dropbutton is meant for "you haven't selected any of these options, select one now", instead of "this is your current option, you can switch to a new one if you want." Going to start on the popbutton.

#19

Now that I think about it, we could also extend the existing dropbutton. I think this is the way to go.

#20

I dont know implementation details of how to do that, but extending the existing dropbutton *sounds* better to me.

#21

Currently the language switcher is output as plain links, we should either alter them only for seven or have a dropbutton also in the default theme. Not sure this would be a good choice. Again a word from @Bojhan would be welcome.

#22

Status:active» needs review

Here's a simple patch and screenshot.
The main problem that active item by default does not show active language, suppose language_negotiation_get_switch_links() needs to be modified to order the list

Another issue that default block title is too big and probably we need to ship 2 css files to make this block float (rtl second one)

lang-block.png

AttachmentSizeStatusTest resultOperations
1498880-lang-22.patch653 bytesIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1498880-lang-22.patch. Unable to apply patch. See the log in the details link for more information.View details | Re-test
lang-block.png23.87 KBIgnored: Check issue status.NoneNone

#23

Issue tags:-needs initial patch

Also it's possible that block should know the default language and make a sort inside

#24

Status:needs review» needs work

The last submitted patch, 1498880-lang-22.patch, failed testing.

#25

In #1874102: Rename language switcher blocks (to differentiate content and UI) we agreed about going for a just "Language" as title, if only one configurable langauge is enabled. This will probably happen in #1833022: Only display interface language detection options to customize more granularity .

#26

Status:needs work» needs review

Not sure I get how to make default title for block, but it's title is not affected by the patch.

Just fixed tests

AttachmentSizeStatusTest resultOperations
1498880-interdiff-26.txt1.23 KBIgnored: Check issue status.NoneNone
1498880-lang-26.patch1.87 KBIdlePASSED: [[SimpleTest]]: [MySQL] 49,068 pass(es).View details | Re-test

#27

Can we get a screenshot of the language switcher in Bartik?

#28

Configuring a block
lang-block.png
Switch language (closed)
lang-bartik1.png
Switch language (open)
lang-bartik2.png

AttachmentSizeStatusTest resultOperations
lang-block.png30.27 KBIgnored: Check issue status.NoneNone
lang-bartik1.png20.92 KBIgnored: Check issue status.NoneNone
lang-bartik2.png18.86 KBIgnored: Check issue status.NoneNone

#29

Thanks, looks acceptable to me in Bartik too. As you were saying we probably need to change the order of links so that the current one is always first, i.e. the visible one.

#30

Here is block config patch. Now it is possible to configure how you want to show languages in the block

  1. As a HTML list
  2. As JavaScript operations
AttachmentSizeStatusTest resultOperations
1498880-block-config-30.patch3.35 KBIdleFAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1498880-block-config-30.patch. Unable to apply patch. See the log in the details link for more information.View details | Re-test

#31

Issue tags:+#SprintWeekend

Adding #SprintWeekend tag

#32

Status:needs review» needs work

Functionally the patch looks good to me, but it seriously needs more styling work as now the language switcher has no margins and looks sloppy on most seven pages. We could consider floating the language switcher on the right to match Bojhan's proposal: #1282018-99: Improve UX of language-aware entity forms.

+++ b/core/modules/language/lib/Drupal/language/Plugin/block/block/LanguageBlock.php
@@ -31,6 +40,29 @@ function blockAccess() {
+        'theme' => t('HTML List'),
+        'type' => t('JavaScript operations'),

These labels do not look very user-friendly to me. What about:

  • List
  • Dropbutton

+++ b/core/modules/language/lib/Drupal/language/Plugin/block/block/LanguageBlock.php
@@ -49,6 +80,17 @@ public function build() {
+      // Attach some logic.

This comment is not very informative.

#33

Issue tags:-challenging+medium

updating tags, looks a bit more reasonable (medium instead of challenging) with some specific things to fix.

also updating issue summary remaining tasks.

#34

Issue tags:+frontend

Tagging to show on the frontend section of http://www.drupal8multilingual.org/

#35

Assigned to:Gaelan» Anonymous

it's been a while. I think ok to unassign.
@Gaelan post to get back into it. :)

#36

YesCT: That's fine. I should have done so earlier.

#37

Status:needs work» needs review

#22: 1498880-lang-22.patch queued for re-testing.

#38

#30: 1498880-block-config-30.patch queued for re-testing.

#39

Status:needs review» needs work

The last submitted patch, 1498880-block-config-30.patch, failed testing.

nobody click here