How to have ONLY the language switcher block (no link or icon in the nodes) ?

Files: 

Comments

Would be interested in that too. There's no sense in having both, a global and a per-node language switcher. Sounds like this is just a bug with the needed option still missing in the 6.x branch...?

Title:Language switcher blockRemove language links from nodes and use language switcher block only
Category:support» feature

Basically you can add this to your custom module and it'll do the trick. Make sure to replace CUSTOMMODULE with your module's name.

<?php
/**
* Implementation of hook_link_alter() to remove language links.
*/
function CUSTOMMODULE_link_alter(&$links, $node) {
  foreach (
$links AS $module => $link) {
    if (
preg_match('<^node\_translation\_>', $module)) {
      unset(
$links[$module]);
    }
  }
}
?>

I hope that someone will that make that a configurable option in the i18n module before I've learned how to write a custom module, because that could take a little longer :-D

I agree completely !!!
I can take the proposition as a temporary solution but it is preferable to have an option into the module.
If we (the users) must change the code ourself then I don't see the advantage of an CMS tool ...
It 's my opinion of course ;-)

Much nicer, just put this in your css file:

a.translation-link{
display:none;
}

So you don't have to mess with the module itself!

That works fine! Thanks!

Explain please !
The css file of the current theme ? if yes, I am using the DECO theme (style.css) and that doesn't work !

I'm using the default Garland style and had to put it into files/garland-dd4bce3e/style.css because after I had configured the scheme in the drupal config menu, it created this subdirectory in files/ which would overrdige the style.css in /usr/share/drupal/themes/

Thanks Drewish,

Spent a while trying to figure out where they get added and how to override it... but your solution will work. Nonetheless I agree with the others, it would be great if some nice person created a configuration option for this.

If a config option is created, there should be an option for teaser view or page view. In my case I want the link flags on page view but not on teaser view.

It's conceivable that a user might want to switch the language of their page, but it's a bit ridiculous to look at teasers in English and then want to read the full article in German!

css trick works, thanks

Not for me with Deco theme !

i would like to not display the translation-link only in the teaser. In the complete view of the node the link should appear. is that also possible with css?

This might help. Otherwise I'm not sure. http://drupal.org/node/170065

the css display:none works for me too, but two elements remain, like >> and | items that previously separated the translation links.
They're called something like translation_links_en and translation_links_es.
How can I remove those wit CSS?

Works nice for me to:
Added "a.translation-link{display:none;}" in content section of style.css.
No elements remain.
I'm using admire_gray theme

If you doesn't want >>

Change just #main by your id

CSS

#main .node .links{
display:none;
}

StatusFileSize
new684 bytes

Please note that css will only disable displaying. The links html will still be there and you might don't want it.

For example search engines or special css browsers ( browsers for blind persons ) will still show the links and follow them.
If you are concerned about SEO you might think that having two urls on your website which points to the same content (eg: it/node/25 and en/node/25 ) is not a good thing.

This is why I implemented the drewish solution above in a simple module which you find attached.

Hope this helps.

Fabio Varesano

Why don't you submit this as a configure option to the i18n module? That would be great :-)

I think the cleanest solution would be to tackle this in core since that's where the links come from. Figure out where in core the links are being added and then enable a configuration variable that causes them to not be added, if set. It would have to be a 7.x feature request. Once we know it's in 7.x, we can settle for using custom modules to strip them out in the meantime.

Whether anyone has the time & motivation to go ahead and do this of course... is another issue.

The language switcher block should switch the interface language and with that, it should switch the content language, too. The language switcher at the bottom of the content should be used to switch the language of the current content only, and nothing else (but indeed it also changes the interface language). I think, that's what this thread is about.

So in short the links should read similar to this:
Language switcher block: mydomain/desired-lang/node/desired-lang-nid
Language switcher at node bottom: mydomain/current-lang/node/desired-lang-nid

where mydomain/lang could also be mylangdomain, depending on language configuration.

Until someone submits a patch to put this in core, the module approach is definitely the way to go, for a variety of reasons listed above this comment.

Thanks for the code !

-- @Themers -> it takes two seconds to implement this, and being able to do a module is surely a very powerful skill to be have - don't be scared of messing with it!

Thanks alot Fabio. I added your module and it works fine!

@#21: This wouldn't make any sense. You should not show a german page with a mydomain/en/blabla path. The lang prefix in a path must match the language of the current content for thinks like pathauto to work. And changing the content of the page without changing the interface language cannot work with user defined menus and localization etc.

I don't understand your problem. For switching the interface language, the language switching is for. If I only want to see the translation of the node, I don't see any need to switch the interface language. I can manually enter the node ID in the URL and everything works well: The interface elements are displayed in the language determined by the path and the content elements (including menus) are displayed in the content's language.

What I can enter manually, I would expect the node's language links to do automatically.

Hmm, maybe I misunderstand some terms here. What do you consider the "interface" language? If I switch afrom english to german, I expect to change everything, i.e., the currently shown content, the (used defined) menue which has the menu entry for this content, stuff like the button texts ('search' -> 'Suche') that I use in html forms in the content. Even the primary links menu must localize if I linked the current content from the primary links.

What do you think should stay in english in this case? The administration pages for example?

I guess it was done like this in 5.x, but I'm not sure if this distinction wasn't dropped in 6.x. I think I read sth. like that in a thread, but I'm not sure...

The interface language is determined by the language prefix in the URL or by the domain. The node will be displayed in it's defined language. Thus you can display an English node while the interface language is set to German.

Presuming the themer knows what languages the site will be using, couldn't the themer just add
  if ($links[node_translation_en]) unset ($links[node_translation_en]);
for each language needed (this one is for English, obviously) to the top of an overridden theme_links() function?

This seems less work than creating a module to do about the same thing, but maybe I'm way off.

You can easily add the following code to your template.php to filter out all translation links from nodes:

/**
* Remove translation links.
*/
function YOURTHEMENAME_links(&$links, &$attributes) {
  foreach ($links as $key => &$value) {
    if ($value['attributes']['class'] == 'translation-link') {
      unset($links[$key]);
    }
  }
  return theme_links($links, $attributes);
}

This may not be the best practice because it senses for the class "translation-link" but it works fine for now.

Would be great to have an option in locale to hide these links.

Thanks Fabio! It seems to works.

I am new to this, so it took me a while to understand I need to delete the "_" from the downloaded file....Anyway I installed to my site/all/modules directory and it looks good.

Assigned:Unassigned» catch

I'll post a patch for the initial feature request later today.

Status:Active» Needs review
StatusFileSize
new1.98 KB

Here's the patch. We add a new field on the i18n settings page, and hide the links if the variable is set.

Status:Needs review» Reviewed & tested by the community

Patch looks good and works great!

Cheers,
Stella

StatusFileSize
new2.45 KB

Slightly modified patch - it just adds in a call to variable_del() in hook_uninstall() on the new variable.

Thanks for review and the variable_del() addition, missed that one.

Issue tags:+i18n sprint

Status:Reviewed & tested by the community» Closed (duplicate)

Committed the patch in #349193: additional language support level that also includes this feature

Doesn't really work for me. I can still see the languange links under the node regardless of the Content Type settings. Any ideas why?

Thanks!
Bence

Title:Remove language links from nodes and use language switcher block onlyitaly
Assigned:catch» tina1

u have an check box (Hide content translation links) in admin/settings/language/i18n for drupal 6 and it hide the language links

Title:italyRemove language links from nodes and use language switcher block only
Assigned:tina1» Unassigned

Reverting title... was assigned to catch also :Z

Issue summary:View changes

Based on the idea from #29 here's the Drupal 7 Version:

<?php
/**
* Remove translation links.
*/
function THEME_links($variables) {
 
$links = $variables['links'];
  foreach (
$links as $key => $value) {
    if (isset(
$value['attributes']) && $value['attributes']['class'][0] == 'translation-link') {
      unset(
$variables['links'][$key]);
    }
  }
  return
theme_links($variables);
}
?>

You can find my blog article about it here: http://julian.pustkuchen.com/node/601