You can set only one data-culture
attribute, a language code, in the popup script for a single domain. However, you can use a plugin such as the WPML to have multiple languages on one domain for WordPress websites. You can find instructions on the plugin's official page.
Note: The data-culture
attribute controls the language in which the popup will appear on the page. For example, setting data-culture = "EN"
will display the popup in English. Set the data-culture
attribute to a different language code to change the language. For more details, see this article.
Alternatively, you can create a script that detects the language code in the URL and adjusts the data culture accordingly. This would work if your domain structure is as follows:
Here’s an example of such a script:
<!--<script type="text/javascript">
// Get the current URL
const currentUrl = window.location.href;
let languageCode = ""; // Check if the URL contains language codes
if (currentUrl.includes("/da")) {
languageCode = "DA";
} else if (currentUrl.includes("/no")) {
languageCode = "NO";
} else if (currentUrl.includes("/sv")) {
languageCode = "SV";
} else if (currentUrl.includes("/fi")) {
languageCode = "FI";
} else {
languageCode = "EN"; // Default to English
} // Set data-culture attribute based on the language code
document.getElementById("CookieConsent").setAttribute("data-culture", languageCode);
</script>-->
If you want to use that script, customize it by updating the language codes to match those used on your domain.