0

I'm looking at a Drupal 6 site with the following modules installed, all of which I think are contributing to translation:

  • Internationalization
  • Locale
  • Content Translation

As I am not experienced with site translation I'm not sure which module is contributing to this, but the "Language Switcher" block shows both English and French for all content, regardless of the language choice assigned in the node, or if there are any translations present.

It is claimed that previously, if there was only an English translation for the node, then only English would be available from the language switcher block. However, if I add a new node, with just an English translation, I can still select French, which, because there is no translated node, takes the user to the internal node path, e.g. instead of:

/en/mycontent/foo

it would be

/fr/node/232

which of course, breaks contexts and what-not.

So what module does the language switcher block get provided by in this case and should it always show both languages?

1

"Switch Language" block created by "Locale" module which is the most fundamental language handler in drupal. Its purpose it to switch user interface between languages. If translation exists for certain node it will used if not, only interface changes.

"Content Translation" module handles relations and links between translated nodes. The link you need is something like the language link/s that, by default, displayed inside node's links area.

I am not aware of existing module that display these node links in block. But you can display this list using code.

First, get can get an array needed links using translation_link() that supplied by "Content Translation" module

$node_translations = translation_link('node', $node_object);

Than, create HTML list out of that array, using theme_links(),

print theme('links', $node_translations, $attributes = array('class' => 'links langs more-classes-if-you-wish'));

To display this in block you can create new custom block with php input format or create template file for that block and make your code live there. To get node object in block you can use

  if (arg(0) == 'node' && is_numeric(arg(1))) {
   $node_object = node_load(arg(1));
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.