Last updated January 13, 2012. Created by dagomar on February 26, 2008.
Edited by Kristen Pol. Log in to edit this page.
It was my wish to have a language switch block that excludes the current language. I have 2 languages set up, so now it will display either "Nederlands" or "English". The block provided by the module doesn't do this. I created a block with php enabled. Then i used the following script (copied from the original block, and slightly modified)
<?php
// modified function
function excl_translation_get_links($path = '', $query = NULL, $names = NULL) {
$current = i18n_get_lang();
$names = $names ? $names : i18n_languages('native');
foreach (array_keys(i18n_supported_languages()) as $lang){
if ($lang != $current) {
$url = translation_url($path, $lang);
$links[]= theme('i18n_link', $names[$lang], i18n_path($url, $lang) , $lang, $query);
}}
return $links;
}
$lang_list = theme('item_list', excl_translation_get_links($_GET['q'], empty($query) ? NULL : $query));
echo $lang_list;
?>that will put out a list of the available languages, excluding the active language!
I was looking for this a long time, so hopefully this can be of some help for anyone.
Comments
Only works if "Interface language depends on content" is used
If you have configured your Language Management setting to be "Interface language depends on content." this works. But if, as I do, use the "Interface language is independent" setting this will not work. All it will do is to show your secondary language(s) twice.
Here's an adapted version
Here's an adapted version for Drupal 6.x: http://drupal.org/node/242646