I have hunted for a solution and am surprised I have not found it yet. I gave a presentation to a department at my university about using drupal as a mutilingual website detailing, well, university stuff. A question arose about switching the user interface language ONLY using a dropdown selection box. I did not have an adequate answer...DOH! My fault for not being better prepared. However, I assumed (yeah my bad) as locale.module offers multiple language capability for the UI, it would also offer a means to switch between them. Nope. Boy, was I surprised. I've downloaded and fiddled with the international module. Very nice EXCEPT I don't like using flags (native language names make more sense IMO) and a drop down box is not used for language selection. My question is, does anyone know of a simple way to create a block with a drop down selection menu of available UI languages created by the locale.module? If necessary, I can also use the internationalization module...it's nice but more than I currently need.

thanks,

wim

Comments

battochir’s picture

that's impressive!

tony@greenhousekeeper.cn’s picture

language switch drop down box, Have you found one at the user interface level?

www.greenhousekeeper.cn

brf123’s picture

I put the following in the page.tpl.php:

<?php
    $query = drupal_query_string_encode($_GET, array('q'));
        $path = $_GET['q'];
        $lang = translation_get_links($path, empty($query) ? NULL : $query);
        $current_lang = i18n_get_lang(); // Look up current language with a call to this i18n function, setup link array elements.
        $active_lang = i18n_languages('active'); // loop up al enabled languages
        $names = i18n_languages('native'); //look up alll native names
?>
<form action="">
<select id="el06" name="language" onchange="window.location.href='/'+this.options[this.selectedIndex].value;">
<?php
    foreach (array_keys($active_lang) as $lang){
    $url = translation_url($path, $lang);
        $output = '<option ';
        if ($lang == $current_lang) {
            $output .= 'selected ';
        }
        $output .= 'value="';
        $output .= i18n_path($url.'?'.$query , $lang);
        $output .= '">';
        $output .= $names[$lang];
        $output .= '</option>';
        print $output;
  }
    ?></select>
</form>

What I can't figure out is how to get the flags in there!

brf123’s picture

A simple if statement solved the flag issue. FYI.