Skip Navigation

This thread is resolved. Here is a description of the problem and solution.

Problem:
The client is trying to set up a custom icon for languages in WPML and ensure the mobile version of the language menu appears as a horizontal list. The custom icon was not added in the correct format, and the mobile version of the language menu was displaying vertically instead of horizontally.

Solution:
1. We corrected the 'Default flag format' in WPML -> Languages from SVG to PNG to match the client's image format. For using SVG images, a different plugin is required to add SVG support. More details can be found here: Custom Language Flags.
2. We adjusted the CSS for the mobile menu to display the language switcher horizontally by adding the following code in Theme -> Customize -> Additional CSS:

.elementor-nav-menu li.wpml-ls-item {
    border-width: 0;
    display: inline-block;
    width: 36%;
    font-size: 10px;
}

.wpml-ls-item a.elementor-item {
    font-size: 12px!important;
}

Further customization tips for the language switcher can be found here:

If this solution does not resolve your issue or seems outdated, we recommend checking related known issues at https://wpml.org/known-issues/, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If the problem persists, please open a new support ticket at WPML support forum.

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by Waqas Bin Hasan 7 months, 3 weeks ago.

Assisted by: Waqas Bin Hasan.

Author Posts
October 18, 2024 at 10:38 am #16303771

felixR-25

Background of the issue:
I am trying to set up a custom icon for languages (an icon of the world) in WPML - Languages - Site languages. I need this icon to be next to the written English and Swedish language switcher and it should be clickable as the name of the languages. I have created two menu options for languages, one for the desktop version and another one for mobile. In the mobile version, I determined it to be a horizontal list, but it appears as a vertical list in the design. And also why it is not visible? Even though if we go on mobile version and we can see that there are two extra buttons where specifically this plug in applied.

Symptoms:
The custom icon is not added in SVG or PNG format. The mobile version of the language menu appears as a vertical list instead of a horizontal list.

Questions:
How can I set up a custom icon for languages in WPML?
How do I ensure the mobile version of the language menu appears as a horizontal list and why it is not visible on mobile however we can see that there is a container?

October 18, 2024 at 11:08 am #16304087

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Reference to our recent chat, I need to take a closer look at your site. So I request temporary access (WP-Admin and FTP), preferably to a test site where the problem has been replicated.

Your next answer will be private, to share this information safely.

Also provide detailed steps to reproduce the issue and links to pages in the admin and on the frontend.

IMPORTANT: Please take a complete backup of the site to avoid data loss. I may need to activate/deactivate plugins also.

See https://wpml.org/purchase/support-policy/privacy-and-security-when-providing-debug-information-for-support/ for details on privacy and security.

Regards.

October 18, 2024 at 11:59 am #16304587

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the access and details, I am checking for the issue and 'll update you shortly on this.

October 18, 2024 at 12:35 pm #16304707

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your patience and cooperation. The issues are fixed, please check your site as well as attached images.

Some points to be noted:

- Your had set "Default flag format" to SVG in WPML -> Languages, while image was PNG. So I corrected that and used your png globe image.
- The image is 150x150, while recommended is 18 x 12.
- If you want to use SVG image, you 'll need a different plugin to add SVG support. See https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/custom-language-flags/#custom-flag-requirements for details.

- For the horizontal vs vertical language switcher in mobile, I've fixed the CSS by adding following in the Theme -> Customize -> Additional CSS:

.elementor-nav-menu li.wpml-ls-item {
    border-width: 0;
    display: inline-block;
    width: 36%;
    font-size: 10px;
}

.wpml-ls-item a.elementor-item {
    font-size: 12px!important;
}

- Same CSS fixes that language names looking like a line in the mobile menu. Because font-size was set to 1px.

Please feel free to adjust the CSS as per your likings. Also see following for more details on Customizing a Language Switcher with CSS:

- https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/how-to-fix-styling-and-css-issues-for-the-language-switchers/#customizing-a-language-switcher-with-css
- https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/custom-language-switcher/#the-styling-part

Screenshot 2024-10-18 172616.jpg
Screenshot 2024-10-18 172557.jpg
Screenshot 2024-10-18 170612.jpg
Screenshot 2024-10-18 170432.jpg
Screenshot 2024-10-18 170412.jpg
lsworld.jpg
October 18, 2024 at 3:02 pm #16305354

felixR-25

Thank you so much for your assistance. I can see that now we have world icon on its place.
Now we have another question, which is still connected to this topic.

1. Why the world icon has such a bad quality? i have tried several times to save it in bigger format but still no success. I am attaching image in png of the world icon that we need there.
2. Second question - Why the world icon is not visible next to Svenska language on the home page (desktop version)? I am including a screenshot of that. We would like to have the world icon next to both languages: Next to English and a drop down language Sweden.

Thank you in advance for your amazing help!

world icon.png
Screenshot 2024-10-18 164754.png
October 21, 2024 at 4:33 am #16309830

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for your message, please consider following:

1) Because you're using a way too big image (1103px x 662px) while recommended size is 18px x 12px.

2) For the other language, please also use the same "Custom Flag" option in WPML -> Languages -> Edit Languages. I added that icon for English only to showcase. You can add it to the other language(s) as desired.

Please see the previously provided guides for more details.

October 21, 2024 at 8:35 am #16310842

felixR-25

Thank you Waqas Bin Hasan for your reply!
Unfortunately I still need your assistance.

I have followed all your recommendations about size of the flag image (it is 18 by 12 px now) and also that it is added to the second language.
Which problems we still have:

- The world icon still does not appear next to Swedish language on a dropdown menu in desktop version. (screenshot included)
- Why the world icon still appears in a such bad quality, even thought now the dimensions are correct (18 by 12 px)?
- How to increase the font size for languages name? If i go to Style section in the WPML menu, i increase it but there is no visible increase of it.
- How to make less spacing between the WMPL container and others? Again if i check advanced settings, everything is correct.

Looking forward to your reply.

Screenshot 2024-10-21 103300.png
Screenshot 2024-10-21 102356.png
October 21, 2024 at 1:16 pm #16312445

Waqas Bin Hasan
WPML Supporter since 05/2014

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Thank you for the updates.

WPML comes with very plain and default set of styles and allows themes and other plugins to override it. So apparently these issues are not related to WPML but the styling being applied in your site.

I'll request to use browser's inspector to observe the styles being applied to the certain (intended) parts, play with it to achieve your desired results and then apply those final styles (i.e. save) to the appropriate location (i.e. theme customizer's advanced CSS section, your own styles CSS or etc). Please see hidden link how you can use browser inspector in different browsers.

As long as the image quality is concerned, not every image looks great when it is resized. Some pixelate when upscaled while other look messy when downscaled. Generally, you should use a sharp image for such smaller sizes (i.e. no gradients or grey-scales).

For the icon, not displaying with Swedish language, perhaps either changes are not being applied, or caching is in play. You can force reload the page, clear browser and site caches and/or disable caching plugin while working at it.

You can also clear/disable language switcher cache in WPML -> Support -> Troubleshooting.

Additionally, you can also try on this sandbox site (hidden link one-click login). Here, I've configured WPML while you can activate Elementor and switch to Hello Elementor theme and reproduce the issues. You may also try with a default WP theme like 2021.