Hello all

when nodes have a selected language, and there is no translation for them, language switcher block points to an untranslated version of the node (in my case, a semi translated version, as some contents in the node are strings), and the whole user interface gets puzzled.

I assume that language switcher links, when the node is specific for a language (not language neutral), should check if exists a translation for that node, and in case it doesn't, point to an empty page or to some sort of "this page is not available in your language" page.

Have anyone experienced this? Any workaround?

Comments

haggai_e’s picture

I believe I am also suffering from this bug in version 5.x-2.5. Translated nodes have the language switcher links point at the right nodes, but untranslated nodes have both links (even the one of the current language) point to different unrelated pages.

Haggai

jose reyero’s picture

Status: Active » Closed (works as designed)

When there's no translation, the link if present should switch the interface language but point to the same content.

I don't know any better option

martin_q’s picture

Category: bug » feature
Status: Closed (works as designed) » Active

What about making the links (optionally) disappear in the language switcher if there is no translation available for them? That is what my client is asking for, but I wonder whether this would be desirable functionality in a more general case.

pedropablo’s picture

In fact, I ended adding that kind of functionality, not displaying the link if the node was not translated for links inside node (but I did it through content template module, invoking the block just when the content is translated)

But I also needed a global switch on every page, so it would be great if both options were available (not displaying links or display an specific page)

The problem when directly changing the user interface leaving the content untranslated, is that many users do not understand the change, and depending on how your site is created, certain multilingual elements could not be shown in a proper way (for instance, many of primary menu entries for the new language disappear when switching language to a node which is not available in that language)

For instance, this is the content of a block I created to be invoked from nodes.

if ( arg(0) == 'node' && is_numeric(arg(1))) {
  $node = node_load(arg(1));
  if(!($node->tnid)){
    print $home_link;
  } else {
    // this is copy&paste from locale_block in locale.module
    ....
    ....
  } 
}

where $home_link is a multilingual variable pointing to my untranslated content page (in my case, is the home for the changed language).

Anyway, I think it would be good to have the option to select the block behaviour when the content is not available in the requested language. Those options cuold be:

- Change language and show the original untranslated content
- Do not show the link to that language
- Redirect to a specific page.

s.daniel’s picture

@Jose A Reyero
"When there's no translation, the link if present should switch the interface language but point to the same content."
I have two D6.9 i18n sites where the language switcher block behave exactly like pedropablo says it should - and I agree, not showing links for untranslated nodes makes sense in most cases. I mean there even is a module for being able to switch the interface without the content http://drupal.org/project/languageinterface and here you say that core behaves like I am looking for it: http://drupal.org/node/226877#comment-772813

Als’s picture

Confirm other users who are reporting this bug. I see it in version 5.x-2.5, while in version 5.x-2.2 the language switcher worked as Jose says.
I assume there's something new in v. 2.5 of the module, about language switcher specifically, that breaks it if content is not translated.
If you're going to patch this, would you make it 5.x compatible? Thanks in advance!

binhcan’s picture

Hi pedropablo,

Thanks for sharing such crucial information for a solution to the duplicated content links.

I'm building a site Chinese Classical Furniture in English and I also have problem the language switcher is pointing to untranslated node on the 中国古典家私 in Chinese with the url "/node/x" where x is the nodeid, and vice versa.

I really getting frustrated because this is causing duplicated content and I can see Google is disliking my sites. I've searched few days for a viable solution but... till now still a myth.

My next step will be creating a module that redirect those type of URL to the original node. But for now, I'm in capable of doing so.

I read your comment and feel like you already got a working solution to the current problem. So could you please help me a little bit?

- Is $home_link a drupal variable, or did you declare it?
- Do you have some working demo or some screenshot?

While waiting for your reply I will try your code first, hopefully it works the first try.

Thanks again,
Binh

binhcan’s picture

I tested the code it's not working :(
Did you find some solution? please let me know or I can't sleep. Thanks.

pedropablo’s picture

Hello Binh

I have this setup working on this short stories for children site. It only has 2 languages, Spanish and English, and all untranslated content is in English (I mean, I write the story in Spanish and then I translate some of them -well, just a few :-)... just look for a translated story and an untranslated one to see differences.

$home_link is a variable I declare. Moreover, as I just wanted to point to my home page, in the actual version of the code, this variable is dirty hardcoded in the same bunch of php code...

Hope this helps
Pedro Pablo

binhcan’s picture

Status: Active » Fixed

Hi Pedro,

Thanks.

I fixed this issue by myself. It's very effective solution.

I actiaved the PHP filter module, and added the code to a custom block. It worked fine.

BTW, your site is very nice and helpful. I love things related to education. Keep up the good work.

Cheers,
Binh

s.daniel’s picture

Status: Fixed » Active

The original issue is still open.

balabushka’s picture

This should be implemented into the i18n module - so I see this issue not fixed until then.

neochief’s picture

Status: Active » Closed (duplicate)
Als’s picture

Neochief, would you backport your patch to the D5 version of Translation module?
I tried to apply it straight away, but there are a few differences in the module's code.
I am available for testing.

rolfmeijer’s picture

Not sure if this is helpful but I kind of managed it the following way (and post it here for for archives sake).

I enabled the language switcher-block and added this to the PHP-mode for showing the block:

<?php
$match = FALSE;
if (drupal_is_front_page()) {
  $match = TRUE;
}
else if (arg(0) != 'node') {
  $match = TRUE;
}
else if (is_numeric(arg(1))) {
  $nid = arg(1);
  $node = node_load(array('nid' => $nid));
  if ($node->tnid != 0) { 
    $match = TRUE; 
  }
}
return $match;
?>

Now it displays on the home pgae, on every page that is not a node and on nodes that do have a translation. Because, as I discovered in views, if a node has a tanslation both the original node and the translated node have the same translation node id (tnid). Only if there is no translation the tnid will be “0”.

Btw, I also made a block with the inverse selection so I’m able to show a disabled link. In that case visitors will see there is a translation of the site, but not all pages are translated.
The code used for that is;

<?php
$match = FALSE;
if (arg(0) == 'node' && is_numeric(arg(1))) {
  $nid = arg(1);
  $node = node_load(array('nid' => $nid));
  if ($node->tnid == 0) { 
    $match = TRUE; 
  }    
  else {
    $match = FALSE;
  }
}
return $match;
?>

I guess this will only work for sites with just two languages.