Skip to content Skip to sidebar

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.

Sun Mon Tue Wed Thu Fri Sat
12:00 – 20:00 12:00 – 20:00 12:00 – 20:00 12:00 – 20:00 12:00 – 20:00 - -
- - - - - - -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 3 replies, has 2 voices.

Last updated by Noman 1 year, 3 months ago.

Assisted by: Noman.

Author Posts
May 6, 2024 at 2:28 pm #15597900

murtazaS

Tell us what you are trying to do?
How can I customize the translation switcher in WPML plugin to display as a button and dynamically show the available languages based on the current language of the page content? For instance, if the page content is in English, the switcher should display the option to switch to the second languauge and it should show secondery launguage also

Is there a similar example that we can see?
hidden link
check out launguage switcher of the website

What is the link to your site?
hidden link

May 6, 2024 at 3:43 pm #15598498

Noman
WPML Supporter since 06/2016

Languages: English (English )

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

Hi,

Thank you for contacting WPML Support. I checked the language switcher style on example site and you should be able to achieve it by following the below steps:

1. Go to WPML >> Languages > Menu Language Switcher.
2. Edit the language switcher by clicking on the pencil icon and set the options according to your needs as you can see in the attached screenshot.
3. After that you can use the language switcher CSS selector “wpml-ls-item” and add the button CSS to it. Here an example code:

.wpml-ls-item {
    border: 1px solid #0d5a94;
    font-weight: 600;
    padding: 5px 16px;
    border-radius: 6px;
    background: #f7f8fa;
    color: #0d5a94;
       font-size: 15px;
    letter-spacing: .03em;
}

You may customise it according to your needs.

Here is a doc for more details: https://wpml.org/documentation/getting-started-guide/language-setup/language-switcher-options/how-to-fix-styling-and-css-issues-for-the-language-switchers/

Please let me know if this resolves the issue or if you need further assistance with this issue.
Thank you

language switcher button.png
Edit language switcher 1.png
language switcher style.png
May 7, 2024 at 9:06 am #15600511

murtazaS

Yes Language Switcher Button: The language switcher should be a button or link that indicates the language it will switch to. Here's how it should work:

When the current language is English, the switcher should display "العربية" (Arabic).
When the current language is Arabic, the switcher should display "English".

Additionally, when the user clicks the switcher button, the page's language should immediately change to the selected language.

refrence website
hidden link

May 7, 2024 at 11:28 am #15601466

Noman
WPML Supporter since 06/2016

Languages: English (English )

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

Thanks for the additional details. I visited your site and it seems you have added the CSS to the language switcher to make it look like a button.

1. To remove the flag from Menu Language Switcher, Please go to the WPML >> Languages > Menu Language Switcher and edit the language switcher by clicking on the pencil icon and setting the options as you can see in the attached screenshot.

2. To display the secondary language by clicking on the language switcher button, it is necessary to translate that page into that language first. So, please make sure you have translated your site pages into a secondary language so that it will switch the language when you click on that button.

I’ve tried the same steps on my test site and it seems to be working correctly as you can see in the attached screenshots.

Please let me know if you have any questions
Thank you

Language switcher style 1.png
Arabic page 1.png
English button button.png

The topic ‘[Closed] i need help with launguage switcher button’ is closed to new replies.