The first problem is fairly minor: the English png icon is not an actual png file. It is just 6 bytes. This issue was addressed previously in this forum (https://forum.backdropcms.org/forum/language-icons-english-flag-damaged) about 6 months ago and was noted as fixed but somehow it is back. I copied and renamed the US png icon and that could fix this issue for me except for the big problem that follows.

The second issue is major: the icons do not display and errors are thrown in the report log. I installed Language Icons, via the admin menu installer rather than downloading the module myself, on essentially a fresh local installation of Backdrop (I had installed the Language and Locale core modules and imported the ES (Spanish) interface translations and changed a few basic settings in Site Information like uploading my own logo, adding a slogan, etc.

I went to the Language Icons settings page (in Config/Language) and noted that the path to the icons is correct (modules/languageicons/flags/*.png). I added a language switcher block and then tried the three settings for "before, after, and replace link" but none worked. 

So I used the built-in method to install the Language Switcher Dropdown module, thinking perhaps it would use the installed Language Icons. That failed to work also. Reading more, it appears that the dropdown module is sort of a cosmetic thing that actually runs the same base code as the regular language switcher, I think.

Where there should be icons (dropdown or the regular list type), there is simply a link and generic pic that indicates missing images. Inspecting the page code, I see that where there should be an icon, there is instead this: 

<img class="language-icon" src="http://XXXXXX.XXX/modules/languageicons/flags/.png" width="16" height="12" alt="English" title="English">

Notice that there is no filename before the ".png" extension. That is exactly the same for the Spanish choice as well, obviously with "alt" and "title" saying "Español" instead of "English."

So I looked in the admin reports at the Recent Log Messages report. I find repeated instances of these messages (presumably as I was reloading the page after trying to fiddle with Language Icons settings, etc).

  • Notice: Undefined property: stdClass::$langcode in locale_language_url_rewrite_url() (line 441 of /var/www/html/XXXXXX.XXX/core/includes/locale.inc).
  • Notice: Trying to access array offset on value of type null in language_switcher_dropdown_form_layout_block_configure_form_alter() (line 51 of /var/www/html/XXXXXX.XXX/modules/language_switcher_dropdown/language_switcher_dropdown.module).
  • Notice: Undefined property: stdClass::$langcode in theme_languageicons_icon() (line 105 of /var/www/html/XXXXXX.XXX/modules/languageicons/languageicons.module).
  • Notice: Undefined property: stdClass::$langcode in l() (line 2908 of /var/www/html/XXXXXX.XXX/core/includes/common.inc).
  • Notice: Undefined property: stdClass::$langcode in locale_language_url_rewrite_url() (line 441 of /var/www/html/XXXXXX.XXX/core/includes/locale.inc).

Disabling Language Icons module gets rid of the "missing" pic icon on the language switcher but also means, of course, that there are no icons on the switcher block. With LI module disabled, no new error mesages are reported in the log.

I just discovered Backdrop a few days ago after some years away from the Drupal world. I am so delighted with it (played for 24 hours with one of the automatic demos) and I really appreciate the hard work of everyone involved in making this possible.

Most helpful answers

This is (was) puzzling, indeed.

Reading the recent comments lead me to an existing issue in the language_switcher_dropdown queue:

Undefined index immediately after installing

I think, the conclusion here is correct - the problem is actually caused by language_switcher_dropdown, the latest release of languageicons (many thanks, @alanmels!) works properly.

I'm so sorry the module is not updated in timely manner. Please give a try to the new version rolled our today on https://github.com/backdrop-contrib/languageicons/releases/tag/1.x-1.1

Also I would appropriate if this discussion was summarized on Github, because that's where we could efficiently work on getting the errors fixed.

I see... so there might be more bugs, still unresolved.

To my understanding the current language (en / es) should be used to construct the filename (en.png / es.png), but the info isn't retrieved properly:

Notice: Undefined property: stdClass::$langcode

So for the moment I'd personally rather suggest to uninstall the module. Sorry, that I can't help more (I never use language icons).

Comments

indigoxela's picture

Hi KrotorVE,

and welcome to the Backdrop community.

I think the problems you're struggling with, have already been fixed in the dev version, so I opened an issue in their queue asking for a new release.

In the meantime you could verify, that bugs are fixed in dev, by downloading the zip file from Github and replacing the old stable release with that.

Caution: these zip files from Github don't have the proper directory name, so you'll have to rename/move it on your own. Or unpack it locally and only upload the contents.

If you find additional bugs in the dev version, please let us know.

Thanks for the welcome and advice.

I removed the language block from the layout then disabled and uninstalled the Language Switcher Dropdown since that module did not seem to be the problem. 

I downloaded the dev via the link you provided, unpacked it, and copied the contents into the existing file structure for the module, overwriting the original files and preserving file permissions and ownership appropriately.

I cleared the caches and message log and reloaded the page (no switcher block and Language Icons not installed). There were no errors afterward.

I enabled the Language Icons module (dev version), clearing caches (won't repeat this but I did it at ever step that follows). Message log showed that it was enabled and no errors. Reloaded the page (again, without switcher block) and no errors.

I added the standard (not Dropdown) switcher block and reloaded the page. The same problem appeared, the "missing pic" icon and inspection shows it as "(path).png" -- that is, no filename just the ".png" extension.

Here are the 8 error messages that appear each time a page is loaded (I cleared the log each time to be sure that every page load reproduces these exact same errors in this order of occurrence (that is, reverse of their listing order in the message log).

Notice: Undefined property: stdClass::$langcode in theme_languageicons_icon() (line 105 of /var/www/html/XXXXX.XXX/modules/languageicons/languageicons.module)

Notice: Undefined property: stdClass::$langcode in theme_languageicons_icon() (line 105 of /var/www/html/XXXXX.XXX/modules/languageicons/languageicons.module).

Notice: Undefined property: stdClass::$langcode in theme_links() (line 1917 of /var/www/html/XXXXX.XXX/core/includes/theme.inc).

Notice: Undefined property: stdClass::$langcode in l() (line 2908 of /var/www/html/XXXXX.XXX/core/includes/common.inc).

Notice: Undefined property: stdClass::$langcode in locale_language_url_rewrite_url() (line 441 of /var/www/html/XXXXX.XXX/core/includes/locale.inc).

Notice: Undefined property: stdClass::$langcode in theme_links() (line 1917 of /var/www/html/XXXXX.XXX/core/includes/theme.inc).

Notice: Undefined property: stdClass::$langcode in l() (line 2908 of /var/www/html/XXXXX.XXX/core/includes/common.inc).

Notice: Undefined property: stdClass::$langcode in locale_language_url_rewrite_url() (line 441 of /var/www/html/XXXXX.XXX/core/includes/locale.inc).

You'll note that some are repeats; I assume that is when it is iterating through the two languages (EN and ES) and thus hits the same error condition.

If Language Icons is uninstalled but I put the standard switcher block on the page, all is fine: no errors in the message log. So this is not a critical thing. I can still have language switching capability. The icons merely dress it up a bit, making it look nicer.

Thanks for your help and let me know if I can supply more information.

 

indigoxela's picture

I see... so there might be more bugs, still unresolved.

To my understanding the current language (en / es) should be used to construct the filename (en.png / es.png), but the info isn't retrieved properly:

Notice: Undefined property: stdClass::$langcode

So for the moment I'd personally rather suggest to uninstall the module. Sorry, that I can't help more (I never use language icons).

Yes, for now I have done just as you suggest. Language icons are an adornment rather than an essential so I will await further developments before trying to use them.

Hello,

This is an interesting problem and I read the discussion carefully because I often use Language Icons module in my work and I have never had such problems or such messages in the message log.

I currently have at least four multilingual sites that use the Language Icons module and they all work normally with the latest version of Backdrop 1.20.1, but also with the previous ones, I have been using this module for more than 4-5 years.

In some older sites I work with the standard multilingual configuration of Backdrop, in two of the new ones I have installed i18n but with or without i18n Language Icons module works normally (except for the missing icon for English - en.png - which I replaced with a similar one). from this module for Drupal 7)

And when checking the HTML code of the page (with Firebug) I see the correct entry:

<img class="language-icon" src="https://mysite.com/modules/languageicons/flags/en.png" alt="English" title="English" height="12" width="16">

This makes me think that the error does not come from the Language Icons module but from something else in the system. In my sites I use my custom layouts and themes, but this hardly has any effect on this problem.

Yes, it is puzzling, isn't it? As I mentioned earlier, this is a fresh installation of Backdrop; I enabled just the two core language-related modules and Language Icons was the first and only external module I had added. Other customization was trivial (site slogan, logo, etc) plus I imported the Spanish interface translations (.po file). I had not even added any content nor content types either.

I think you are right that it may not come from Language Icons. After my last post, I tinkered a bit by adding the Language Switcher Dropdown but without installing Language Icons.

The block doesn't appear as a dropdown but rather as the same generic list as the standard switcher. But there are no errors in the message log.

Configuring the block to show codes instead of languages ("es" instead of "Español") shows the block title, below that "en", and below that two lines each with a large dot (aka, the "unordered list" symbol). 

The error log after each refresh or page change shows:

Notice: Undefined index: language in language_switcher_dropdown_block_view_locale_language_alter() (line 83 of /var/www/html/XXXXX.XXX/modules/language_switcher_dropdown/language_switcher_dropdown.module).
Notice: Trying to get property 'langcode' of non-object in language_switcher_dropdown_block_view_locale_language_alter() (line 83 of /var/www/html/XXXXX.XXX/modules/language_switcher_dropdown/language_switcher_dropdown.module).
Notice: Undefined index: language in language_switcher_dropdown_block_view_locale_language_alter() (line 83 of /var/www/html/XXXXX.XXX/modules/language_switcher_dropdown/language_switcher_dropdown.m
Notice: Trying to get property 'langcode' of non-object in language_switcher_dropdown_block_view_locale_language_alter() (line 83 of /var/www/html/XXXXX.XXX/modules/language_switcher_dropdown/language_switcher_dropdown.module).

 

So, even without the Language Icons module, something is broken. I have no idea what it is though.

I tried installing and enabling the Internationalization module too but there is no change. The same four error messages appear and the supposed dropdown block shows that odd list.

 

I apologize, I wrote from memory and I was wrong. I have several multilingual sites, but mostly they use the standard Language switcher with text language names. I was confused with several sites that use Language Icons module, but they are with Drupal 7. In fact, I have only one site with Backdrop that uses Language Icons module, but I also installed i18n in it, maybe because of that I don't see any errors.

The code in the previous post is from this site - with Backdrop CMS, Language Icons module and i18n.

Thanks for trying to help. The new version does indeed fix the problem of the missing EN icon.

The other issues that I noted above (errors and no icons appearing in the switcher, neither the default type nor the dropdown if enabled) continue. If you skip back up a bit, you'll see that there are problems with the dropdown switcher even if Language Icons is not installed (although no dropdown and no LI works with no error messages).

So I am thinking it may be something somewhere else rather than in the LI module. I might try wiping everything and reinstalling Backdrop from scratch just to see what happens (although this was a 99% fresh install anyway).

Thanks again.

Addendum: I forgot about your last paragraph regarding Github. As I mentioned, it appears that the root of this issue may lie elsewhere than the LI module so I am reluctant to open an issue there and send people on a wild goose chase. Somewhere, somehow it looks like $langcode (variable? array?) is being lost or assigned as null or something but why and where is a mystery.

indigoxela's picture

This is (was) puzzling, indeed.

Reading the recent comments lead me to an existing issue in the language_switcher_dropdown queue:

Undefined index immediately after installing

I think, the conclusion here is correct - the problem is actually caused by language_switcher_dropdown, the latest release of languageicons (many thanks, @alanmels!) works properly.