I'm pretty sure this is easy as I've done multi-lingual before and never had this problem, anyway... here goes :)

I've got a multi-lingual site in two languages with translations. At the bottom of every multi-lingual node I have a link to the translation of that page. For example, next to "Add a new comment" I have "Francais" that links to the French version of the page.

How can I get rid of these links? I have a language switcher block so there is really no need for them.

Thanks,

Adam

Comments

adshill’s picture

Ok so I managed to do it through CSS...

.translation-link {
	display: none;
}

but this is far from ideal as it just leaves a big gap at the bottom of nodes where it would be.

Any help would be greatly appreciated!

dboulet’s picture

I was able to remove these links using the phptemplate_preprocess_node() function. Here's the code to add to your theme's template.php file:

<?php
function phptemplate_preprocess_node(&$vars) {
  $node = $vars['node'];
  // Remove translation links
  foreach ($node->links as $key => $value) {
    if ($value['attributes']['class'] == 'translation-link') {
      unset($node->links[$key]);
    }
  }
  $vars['links'] = theme('links', $node->links, array('class' => 'links inline'));
}
?>

There should probably be a better way to do this; it would be great to be able to configure this within the i18n module itself, but this technique works for now.

boriznl’s picture

Your preprocess function should work, i think but it ist on my site.

I changed the function name, what am i doing wrong?
i have version 6.9 of drupal

dboulet’s picture

What did you rename the function to? If you're using a phptemplate theme, try inserting the code exactly as I've provided it. If you already have the line function phptemplate_preprocess_node(&$vars) { in your template.php file, simply insert the following code on a new line following it:

$node = $vars['node'];
// Remove translation links
foreach ($node->links as $key => $value) {
  if ($value['attributes']['class'] == 'translation-link') {
    unset($node->links[$key]);
  }
}
$vars['links'] = theme('links', $node->links, array('class' => 'links inline'));

Once you've inserted the code, try clearing your cache so that Drupal finds the new function.

boriznl’s picture

the cache was the problem

frames’s picture

/admin/settings/language/i18n

I've got an option there called "Hide content translation links", which is what you want, isn't it?

I believe this is coming from i18n itself, althought I also have Language Icons and Consistent Language Interface. Both recommended.

dboulet’s picture

Thank you frames, I have that option on my site as well. This means that I can remove the code that I had previously provided from the phptemplate_preprocess_node() function.

frames’s picture

Glad to hear I helped.

knalstaaf’s picture

This is also the way to go when using entity translation (see comment of Bohus Ulrych).

knalstaaf’s picture

In Drupal 7 I removed it by unchecking/disabling the language in admin/config/regional/language.

yvesvanlaer’s picture

In D7

/admin/config/regional/i18n/node

Hide content translation links
Hide the links to translations in content body and teasers. If you choose this option, switching language will only be available from the language switcher block.

Check this box and it will be removed... Easy, but hard to find :).

wildseven’s picture

Thanks for that advice. I would also like to remove the line, one above the link.
I could not find any settings for that, and I'm not sure who is writing that into my site...

Language
English
wranvaud’s picture

You need to have the i18n module option "Multilingual content" enabled for this checkbox to appear.

randa.elayan’s picture

wildseven, To remove
Language
English

Go to "Manage Display" tab of your content type, and make the language field display "hidden" :)

commonpike’s picture

confusion all over :-/

/admin/config/regional/i18n/node is part of the i18n module. if you dont have that module installed, you dont have that checkbox. you may still have translated content (and links to it) from the translation module, for example.

i dont have the language appear as a a field, so i cant manage it from "Manage Display" tab of my content type. I assume language might be a field if I use the Entity module, but i dont.

the links i'm looking at are generated by translation_node_view(), defined in modules/translation/translation.module. Its not a theme hook or an alter hook, so i cant hook into it in my theme.

I can only hack that module (yuck) or disable the links with css (yuck twice .. especially since they dont have clear classnames).
If i could remove the links from any *_preprocess_* theme function, i would be very happy, but I cant find where ...

..*stumped*..
*-pike

*-pike

jorisx’s picture

Tried that but it would pop back up into the display list, every time you came back to the "Manage Display" it will pop back up ...
this is seriously annoying ...

got it:
it needs to be set for all the languages at the same time so edit it at the site/nl/admin/structure/types/manage/webform/display settings and edit it at the site/en/admin/structure/types/manage/webform/display settings

jasom’s picture

There is it hidden in d7, thank you

manop’s picture

Thank you so much. I was looking for a while. You save my life.

commonpike’s picture

I installed entity-translation now (and NOT i18n). there is no checkbox to disable the language menu display. language is also not part of the fields of a content type.

Sofar I've only been able to hide them from a node page like this:

function MYTHEME_process_page(&$variables) {
        if (isset($variables['node'])) {
		unset($variables['page']['content']['system_main']['nodes'][$variables['node']->nid]['links']['translation']);
	}
}

hm,
*-pike

*-pike

knalstaaf’s picture

anavrin’s picture

I found this option here: admin/config/regional/i18n/node

Hide content translation links

Dr.Osd’s picture

This option is available, if you enable Multilingual content module and Multilingual select.

batigolix’s picture

This snippet in a custom module removes the language links from the node:

(Beware: it might be a bit too effective as it removes all links from the node)

/*
 * Implements preprocess node
 */

function MYCUSTOMMODULE_preprocess_node(&$variables) {
  unset($variables['content']['links']);
}
arne_hortell’s picture

in file
node--NODENAME.tpl.php
For example
node--article.tpl.php

right before the line of

print render($content);

Add this
hide($content['language']); // this is the added line
print render($content);

This will hide whatever language wants to show in the node.

Nothing is impossible, the impossible just takes a little more time

drup975’s picture

After looking for many hours, I finally found a way to remove the translation links (Drupal 7) on node elements by adding the following code in my page.tpl.php of my subtheme (just before the line print render($page['content']);):

if (isset($node->nid)){
     unset($page['content']['system_main']['nodes'][$node->nid]['language']);}

Hope it can save time to someone!

Bohus Ulrych’s picture

For Entity translation (entity_translation 7.x-1.0-beta3) there is settings for each Structure / Content type. Just edit your Content type, under the Publishing options you will find checkbox "Hide content translation links"

thim’s picture

Just what I needed, as simple and clear solution.
Thnks @Bohus

manish sharma’s picture

In Drupal7, please go to admin/config/regional/i18n/node and select "Hide content translation links"

bmateus’s picture

This is the best way.

Bruno Mateus

medhaj’s picture

/**
* Override or insert variables into the node template.
*/
function theme_preprocess_node(&$variables) {
unset($variables['content']['links']['translation']);
}