Sauter la navigation

Ce sujet est résolu. Voici une description du problème et de la solution.

Problem:
The client needed to customize the language selector with different SVG images as backgrounds for each language (French and Dutch) and wanted to set the font color to white for the currently selected language, as well as apply specific background images when a language is currently selected.
Solution:
We recommended the following CSS to achieve the desired customization:

.wpml-ls-current-language a {<br />    color: white !important; /* Ensures font color override */<br />}<br />.wpml-ls-item-fr.wpml-ls-current-language, .wpml-ls-item-fr.wpml-ls-current-language:hover {<br />    background-image: url('https://cdn.wpml.org/wp-content/uploads/2024/02/bg-lang_left-hover.svg'); /* Background for current French */<br />    background-repeat: no-repeat;<br />}<br />.wpml-ls-item-nl.wpml-ls-current-language, .wpml-ls-item-nl.wpml-ls-current-language:hover {<br />    background-image: url('https://cdn.wpml.org/wp-content/uploads/2024/02/bg-lang_right-hover.svg'); /* Background for current Dutch */<br />    background-repeat: no-repeat;<br />}

We also informed the client that providing custom code solutions or custom CSS is beyond the scope of our support and suggested contacting a web developer or designer for further assistance. Additionally, we recommended checking WPML contractors for professional development services.

Please note that the solution provided might be irrelevant due to being outdated or not applicable to your case. If the solution does not resolve your issue, we highly recommend checking related known issues, verifying the version of the permanent fix, and confirming that you have installed the latest versions of themes and plugins. If you still need assistance, please feel free to open a new support ticket.

Il s'agit du forum d'assistance technique de WPML, le plug-in multilingue pour WordPress.

Il est accessible à tous, toutefois seuls les clients de WPML peuvent y publier leurs messages. L'équipe du WPML répond sur le forum 6 jours par semaine, 22 heures par jour.

Marqué : 

Ce sujet contient 1 réponse, a 2 voix.

Dernière mise à jour par Prosenjit Barman Il y a 1 année et 2 mois.

Assisté par: Prosenjit Barman.

Auteur Articles
Avril 2, 2024 à 9:05 am #15471561

hubert.jerome

Dear support,

As you can see in attached file, I'm trying to build a custom language selector with SVG image as background for each language FR and NL (The SVG shapes are differents)
I managed to do it for both language with this CSS :

.wpml-ls-item-fr {
background-image: url( 'https://cdn.wpml.org/wp-content/uploads/2024/02/bg-lang_left.svg' );background-repeat: no-repeat;
}
.wpml-ls-item-fr:hover {
background-image: url( 'https://cdn.wpml.org/wp-content/uploads/2024/02/bg-lang_left-hover.svg' );background-repeat: no-repeat;
}

.wpml-ls-item-nl {
background-image: url( 'https://cdn.wpml.org/wp-content/uploads/2024/02/bg-lang_right.svg' );background-repeat: no-repeat;
}
.wpml-ls-item-nl:hover {
background-image: url( 'https://cdn.wpml.org/wp-content/uploads/2024/02/bg-lang_right-hover.svg' );background-repeat: no-repeat;
}

But the problem is with the wpml-ls-current-language.

I'm trying to
- Set the wpml-ls-current-language font color to white
- Set a wpml-ls-current-language PER language.
So the wpml-ls-current-language for french would have the same css than .wpml-ls-item-fr:hover
and the wpml-ls-current-language for dutch would have the same css than .wpml-ls-item-nl:hover

Is it doable ?

Many thanks for your help !

Jerome

Capture d’écran 2024-04-02 à 11.01.55.png
Capture d’écran 2024-04-02 à 10.57.49.png
Avril 2, 2024 à 11:58 am #15472595

Prosenjit Barman
Partisan de WPML depuis 03/2023

Les langues: Anglais (English )

Fuseau horaire: Asia/Dhaka (GMT+06:00)

Hello Jerome,

Thank you for reaching out to WPML support.

Based on what you've described, I understand that you're interested in changing the font color to white for the currently selected language and applying specific background images to the French and Dutch language selectors when they are the current language. Here's a conceptual approach you can consider:

- Changing Font Color: To change the font color to white for the currently selected language, you would typically target the `wpml-ls-current-language` class. The CSS property you'd be looking to use is color.

- Applying Background Images: For setting background images specific to the French and Dutch languages when they are the current language, you would need to target the combination of classes that represent the current language and the specific language. You've already identified classes like .wpml-ls-item-fr and .wpml-ls-item-nl for this purpose.

Given these points, your CSS might conceptually look something like this:

/* Set the font color to white for the current language */
.wpml-ls-current-language a {
    color: white !important; /* Ensures font color override */
}

/* French language specific styling when it's the current language */
.wpml-ls-item-fr.wpml-ls-current-language, .wpml-ls-item-fr.wpml-ls-current-language:hover {
    background-image: url('https://cdn.wpml.org/wp-content/uploads/2024/02/bg-lang_left-hover.svg'); /* Background for current French */
    background-repeat: no-repeat;
}

/* Dutch language specific styling when it's the current language */
.wpml-ls-item-nl.wpml-ls-current-language, .wpml-ls-item-nl.wpml-ls-current-language:hover {
    background-image: url('https://cdn.wpml.org/wp-content/uploads/2024/02/bg-lang_right-hover.svg'); /* Background for current Dutch */
    background-repeat: no-repeat;
}

However, As part of our WPML support policy, while we're here to help with any issues or questions related to WPML functionality, providing custom code solutions or custom CSS is beyond the scope of our support. The provided code is for demonstration purposes and may assist in resolving your issue. However, for additional help with custom CSS or design modifications, it's best to contact a web developer or designer. You can also hire a professional developer from here: https://wpml.org/contractors/

I hope you can understand. Please feel free to let me know if there is anything else if you need help with. I will be happy to assist.

Best regards,
Prosenjit

Avril 2, 2024 à 12:27 pm #15472836

hubert.jerome

Fantastic, it worked perfectly !!
Many thanks Prosenjit !