You are here

7 July 2011

How to create custom language switcher. You can write your own tags and classes to get completely custom language switcher.

Source code viewer
  1. $avail_langs = language_list();
  2. foreach ($avail_langs as $lang)
  3. {
  4. $attr = '';
  5. if ($language->language == $lang->language)
  6. {
  7. $attr = 'act';
  8. }
  9. echo '<li class="'.$attr.'">' .l($lang->native, $lang->prefix, array('language' => $lang->language, 'attributes' => array('class' => $attr))).'</li>';
  10. }
Programming Language: PHP