I am trying to show the language swithcer dynamically function -just as on the block but instead on switcher block on the header - page.tpl.php
and i tried with snippets below, but both cases it does not work any idea how it should be how it make work
(as alternative choosing the switcher block to show on the header area does not look right -breaks the theme look, so a snippet into the page.tpl.php should do the job just right)

thank you in advance

<?php
function phptemplate_i18n_link($text, $target, $lang, $query= NULL, $fragment = NULL){
  $output = '<span class="i18n-link">';
  $attributes = ($lang == i18n_get_lang()) ? array('class' => 'active') : NULL;
  $output .= l(theme('i18n_language_icon', $lang), $target, $attributes, $query, $fragment, FALSE, TRUE);
  $output .= "&nbsp;";
  $output .= l($text, $target, $attributes, $query, $fragment, FALSE, TRUE);
  $output .= '</span>';
  return $output;
}
?>

and

<?php
function phptemplate_i18n_link($text, $target, $lang, $separator='&nbsp;'){
  $output = '<span class="i18n-link">';
  $attributes = ($lang == i18n_get_lang()) ? array('class' => 'active') : NULL;
  // $output .= l(theme('i18n_language_icon', $lang), $target, $attributes, NULL, NULL, FALSE, TRUE);
  // $output .= $separator;
  //  $output .= l($text, $target, $attributes, NULL, NULL, FALSE, TRUE);
  $output .= l(t($text), $target, $attributes, NULL, NULL, FALSE, TRUE);
  $output .= '</span>';
  return $output;
}
?>

Comments

mohammed76’s picture

hi.

this does work on my own website, so it's tested.

<?php foreach (translation_get_links($_GET['q']) as $link): ?>
 <?php print $link?> 
<?php endforeach; ?>

thanks

Mohammed al-shar'

Nattiq Technologies

ica’s picture

that worked swiftly Mohammed, nice one

thank you!

jose reyero’s picture

Status: Active » Closed (won't fix)

There are some snippets in the handbook.

robertoguzman’s picture

how i can just hide the link for the current language?

how do i do if i have 4 enable language and i want to show up the translation for 2 language only?

adanbouzoua’s picture

Version: 5.x-1.x-dev » 7.x-1.x-dev

Hi Mohamed

I am testing D7, your code is not working.
How to make this works for Drupal 7 ?

Thanks

calbasi’s picture

Version: 7.x-1.x-dev » 7.x-1.4
Component: User interface » Documentation
Priority: Normal » Minor
Status: Closed (won't fix) » Active

Hi Jose,

Where are the handbook snippets? I've looked for them but I can't find them.

Regards.

jose reyero’s picture

Status: Active » Closed (won't fix)

If they're not there, it is just they're not update for Drupal 7