Hello Tomas,
thanks for your quick reply.
I tried to substitute the flags by my own png, which is described here: https://polylang.pro/doc/the-language-switcher/#customizing-flags . But this didn’t solve the problem, even though the image source is src=”https://…” now.
The problem is output of plain text instead of HTML. Now I saw, that in my first question the HTML opening tag of <img is displayed correctly as left-angle bracket, but in source code output resp. the HTML entity name is displayed, see https://www.w3schools.com/html/html_entities.asp . I think, that causes the wrong output.
Here is the full output of the item for the langugae switcher in the Primary Menu:
<li id="menu-item-390-en" class="lang-item lang-item-5 lang-item-en menu-item menu-item-type-custom menu-item-object-custom menu-item-390-en"><a href="https://www.domain.tld/en/" hreflang="en-GB" lang="en-GB"><img src="https://www.domain.tld/wordpress/wp-content/polylang/en_GB.png" title="English" alt="English" /><span style="margin-left:0.3em;">English</span></a></li>
To avoid this, I tried to remove the esc_html filter for the Primary Menu in the functions.php. Without language flag the output is correctly – without <
and >
(as HTML entities)
This is the output without language flag:
<li id="menu-item-390-en" class="lang-item lang-item-5 lang-item-en menu-item menu-item-type-custom menu-item-object-custom menu-item-390-en"><a href="https://www.domain.tld/en/" hreflang="en-GB" lang="en-GB">English</a></li>
Without changes in the theme functions it’s also possible to use CSS as easy work around to display language specific flags, as I did now.
Here is my solution: I added the PNGs for the provided languages to the images folder of the child theme an added the following two rules to my style.css. And Voila! The languages flags are displayed. I use single before with single : to support this styling also for IE8.
#primary-menu li.lang-item-en:before { content: url('images/en_GB.png') " "; }
#primary-menu li.lang-item-de:before { content: url('images/de_DE.png') " "; }
I hope this solution helps user users of Tiny Framework and the Polylang Plugin as well.
PS: Sorry, the code examples are not correctly displayed, because html entity names are correctly displayed. I don’t know how to mask html entity names in the forum editor.
-
This reply was modified 7 years, 5 months ago by felix76.
-
This reply was modified 7 years, 5 months ago by felix76.
-
This reply was modified 7 years, 5 months ago by felix76.
-
This reply was modified 7 years, 5 months ago by felix76.
-
This reply was modified 7 years, 5 months ago by felix76.
-
This reply was modified 7 years, 5 months ago by felix76.