The language switcher block is designed to hide itself when there is only a single language switch link available. This is correct only if the link's language equals the current language, otherwise the language switcher block should be shown.
Moreover there is an error in the condition that counts the links number.

Comments

plach’s picture

Status: Active » Needs review
StatusFileSize
new3.87 KB

The attached patch fixes the wrong condition and integrates Locale tests to detect this failure.

plach’s picture

Component: locale.module » language system

Cleaning-up the "locale module" issue queue as per http://cyrve.com/criticals.

plach’s picture

StatusFileSize
new3.88 KB

rerolled

plach’s picture

berdir’s picture

#3: locale-631928-3.patch queued for re-testing.

plach’s picture

Issue tags: +Quick fix
plach’s picture

#3: locale-631928-3.patch queued for re-testing.

giorgosk’s picture

Status: Needs review » Needs work
Issue tags: -Quick fix +undefined

#3 patch does not work as advertised

2 language links are presented for a tranlatable node with no translation

giorgosk’s picture

Issue tags: -undefined +Quick fix

don't know how I managed to change the tags

plach’s picture

Status: Needs work » Needs review

@GiorgiosK:

#3 patch does not work as advertised
2 language links are presented for a tranlatable node with no translation

This is the D6 behavior and is not covered by this issue, #518364: Nodes with one language don't affect the language switcher block addresses it.

Steps to reproduce/test this:

  1. Enable two languages, say EN and IT
  2. Enable URL language detection
  3. Enable translation for articles
  4. Enable the language switcher block
  5. Create an article in EN and translate it in IT
  6. Unpublish the IT translation
  7. Visit the EN node with EN as interface language. Expected behavior: the language switcher block disappears.
  8. Visit the EN node with IT as interface language. Expected behavior: the language switcher block shows a link to the EN node with EN as interface language.
giorgosk’s picture

Status: Needs review » Needs work

@plach

I did follow all your steps above on a fresh install of drupal 7.x-beta1
applied patch from #3 I even made sure the patch changes were applied
correctly (inspecting the files with editor)

but still the behaviour is same as before patch

when viewing EN node two language links are present 1 for itself and 1 for the
unpublished translation node

when and anonymous tries to follow translation link gets "access denied"

I have the feeling that #518364: Nodes with one language don't affect the language switcher block should be worked together with this issue because its the generalization of this limited scenario

plach’s picture

Status: Needs work » Needs review

@GiorgosK:

They are not the same issue, so we need two separate ones.

The fact that the patch passes its own test suggests that it's working. You are seeing "access denied" because you are using D7 beta1, while the fix is against the HEAD. I tested the path in #10 with a fresh HEAD checkout this morning before posting it. Correct unpublished translations handling did not get into D7 beta1.

Please be sure to have the latest code before changing the status again.

giorgosk’s picture

sorry @plach I did not know it would make such a difference
with latest dev tarball things are better

but still get the the link to ITSELF - language switcher does not dissapear as per 7. above
8. is as you described

peximo’s picture

I have tested the patch with the latest HEAD as described in #10 and it works as expected.

giorgosk’s picture

Status: Needs review » Reviewed & tested by the community

just tested with latest HEAD
works as described in #10

plach’s picture

@GiorgiosK:

Thanks for your patience :)

giorgosk’s picture

always glad to help ;-)

plach’s picture

StatusFileSize
new3.88 KB

rerolled

webchick’s picture

Hm. I share GiorgosK's confusion. It seems like depending on what we do over at #518364: Nodes with one language don't affect the language switcher block these tests may or may not codify the right behaviour? Should this be committed anyway, or should we smoosh the two issues together since they're so related?

plach’s picture

@webchick:

Well this issue fixes the general behavior of the language switcher, while the other one concerns the relation between the language switcher and the Translation module. As we discussed in IRC, IMO if there is only a single link available and it matches the current language the correct behavior is hiding the block. It's up to modules implementing http://api.drupal.org/api/function/hook_language_switch_links_alter/7 to avoid this situation if it's not the desired behavior.

Anyway, we can mark this duplicate of the other one, but IMO we have two independent, although strictly related, discussions to bring on.

Edit: the tests here won't be modified by what we decide in the other issue.

plach’s picture

Another possibility is that, since the only core module actually dealing with the language switcher block is Translation, we remove the condition on the links number altogether:

<?php
  if (isset($links->links) && count($links->links) > 1) {
?>

becomes

<?php
  if (isset($links->links)) {
?>

This way we would allow other modules to implement self-hiding blocks through http://api.drupal.org/api/function/language_negotiation_get_switch_links/7, which encapsulates most of the logic needed to generate a language switcher block.

webchick’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: -Quick fix

Hm. That's an interesting idea. Anyone else have opinions on that?

Also, removing "Quick fix" because it's a LIE. ;)

plach’s picture

@webchick:

Also, removing "Quick fix" because it's a LIE. ;)

I was in good faith :)

I didn't think we would end up in an architectural discussion, I just wanted to fix that damn parenthesis.

plach’s picture

Status: Needs review » Closed (duplicate)

As suggested by GiorgiosK and webchick, this has been fixed in #518364: Nodes with one language don't affect the language switcher block.

egon.ojamaa’s picture

Hey drupal fans..
Here is the quick fix you need.. http://drupal.org/node/995500
No core hacking, and no waiting for a new release of core with a fix.