I saw this was listed as a problem in some 6.x versions, but I'm having the issue in 7.x-1.0 now.

Comments

alexpls’s picture

I have this problem as well. Although I wasn't able to come up with a fix while briefly looking at lang_dropdown's code, I was able to get the desired look by just specifying this in my page's CSS:

.language-icon{
  display: none;
}

It's not a proper fix, but it works!

Anonymous’s picture

I've got the same problem. In FF is works perfect but in IE, Opera or Chrome its broken: two icons placed, one icon works, one icon is missing

chiappa’s picture

Same thing. I tried Safari, Chrome & IE 8. All of them showed two flag icons, the other one being smaller for the default language. When changing to another language one of the icons turns into a question mark box.

The CSS trick from Alexpls fixed that for the default language in all of the browsers mentioned. For the other language it shows again two icons but this time both are question mark boxes.

eldarkhan’s picture

WOW. This is crazy but I went to languages > icons and set the size of icons 0 x 0. This is soo wrong, but it works ;)

Anonymous’s picture

@eldarkhan: Yeah, it only works at the default language site, not the other language. When I switched to other language site, no language icons showed and on both site, it gave the error as follows:

Notice: Undefined offset: 1 in theme_languageicons_icon() (line 120 of /mnt/home_folders/websites/jx2rehab/web/sites/all/modules/languageicons/languageicons.module).

Anonymous’s picture

Can't even get rid of it now... :( So annoying.

How can we make the dropdown icons properly?

Any more suggestions? Thanks!

karens’s picture

The problem is in the function lang_dropdown_form(). It is receiving an array called $language that has the language links with the icons already added to them, and then is adding the icons again.

Two parts of the code in that function need to be removed or adjusted for the fact the the icons are already there:

    // Handle flags with Language icons module using JS widget.
    if (module_exists('languageicons') && $settings['js_widget']) {
      $language_icon = '';
      $languageicons_path = variable_get('languageicons_path', drupal_get_path('module', 'languageicons') .'/flags/*.png');
      $js_settings['languageicons'][$lang_code] = url(str_replace('*', $lang_options['language']->language, $languageicons_path));
      ($settings['languageicons']['flag_position']) ? $flag_position = '#suffix' : $flag_position = '#prefix';
    }

and

  if (module_exists('languageicons')) {
    //$form['lang_dropdown_select'][$flag_position] = $language_icon;
  }

Deleting that code altogether fixes the problem for me.

zoszabo’s picture

Resizing the icon worked for me too (removing the code does not:( ), but when i change language the icon disappeared if I don't use the original language.
I use the URL path to distinguish different languages therefore the new path after language change changes something in the path for the icons as well...
Can anyone help?

ytsurk’s picture

removing the code like in #7 works for me

floretan’s picture

Version: 7.x-1.0 » 7.x-1.x-dev
Priority: Normal » Major
Status: Active » Needs review
StatusFileSize
new2.76 KB

I can confirm what Karen mentioned in #7. The icons are already part of the markup (working) and are also added using javascript (currently broken). The only reason why this seems to work in Firefox is that broken images are hidden by default. Missing images are requested on every page load, resulting in an additional server load.

Here's a patch that removes the code mentioned in #7, as well as the corresponding javascript code which isn't needed anymore.

danny englander’s picture

For some reason the patch did not work for me, I tried:
git apply -v lang_dropdown_duplicate_icons-1328728-10.patch

However, simply removing the code in #7 worked.

manfer’s picture

The problem is that things are mexed up in drupal 7 version.

First and just to clarify this simple thing, the following piece of code does not really matter as $language_icon is always a blank string so that code is doing nothing at all. What this code was supposed to do in my opinion was to include the icon of current language appended or prepended to the select box when no dropdown js library is used but as it is now it is doing nothing.

  if (module_exists('languageicons')) {
    $form['lang_dropdown_select'][$flag_position] = $language_icon;
  }

Another thing to notice to understand all this issue is that the dropdown js library does not support to configure the place where to add the icon. On that library icons are always placed before the text. Though it is possible to move the icon after the text with CSS just coding a skin as dropdown library is skinable -in fact it comes with two skins-. A custom style can be added to dd.css to show the icon after the text and to choose the correct skin there is a parameter called "mainCSS".

This module is using the js library to add the icon and at same time is using the title from the language link in the code:

$options += array($lang_code => $lang_options['title']);

But that title has been hooked by language_icons module and includes the icon.

Because of this last line of code when you configure the language dropdown switcher block without the dropdown js library then the select shows something like:

English <img src="..." ...>

without rendering the image.

---------

For all that in my opinion the solution would be first to remove the icon included by language_icons not using the title of the language link but the native language string.

$options += array($lang_code => $lang_options['language']->native);

That solves all the issues, the select without js dropdown library will show correctly and when using the js dropdown library only one icon will be shown.

But with that solution we lost the ability to choose the icon position (before/after) so to solve that we will need an alternative CSS to add to dd.css dropdown js library. A style that could be used to show icon after the text and could be passed as another argument to the function that creates the dropdown.

The only other thing that would need to be solved is to restore the inclusion of the icon before or after the select when the js library is not used and I thik that could be achieved with several changes, more or less restoring code that still is in the 6.x version. The lang_dropdown.css needs to be changed too because the selector of the select changes in drupal 7.

I attach a patch with all the changes.

manfer’s picture

I attach a new patch that besides doing what previous patch does, it upgrades msdropdown js library to last version 2.37.5 too.

manfer’s picture

Needed a minor change in the msdropdown style that allows to show icon after the text as it was not working correctly in safari nor chrome.

manfer’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.