force language on calendars and links

PHOTO EMBED

Wed Jul 10 2024 12:51:40 GMT+0000 (Coordinated Universal Time)

Saved by @Shira

<script>
$(document).ready(function() {
    // Check the language of the page
    var lang = $('html').attr('lang');
    
    // Define the language parameter based on the page language
    var languageParam;
    if (lang === 'es-ES') {
        languageParam = 'es';
    } else if (lang === 'en-US') {
        languageParam = 'en';
    } else if (lang === 'ca') {
        languageParam = 'ca';
    } else if (lang === 'fr-FR') {
        languageParam = 'fr';
    }

    if (languageParam) {
        // Modify scripts with src starting with the specified URL
        $('script[src^="https://fareharbor.com/embeds/script/calendar/bellesguardgaudi/"]').each(function() {
            var newSrc = $(this).attr('src') + '&language=' + languageParam;
            $(this).attr('src', newSrc);
        });

        // Modify links with href starting with the specified URL
        $('a[href^="https://fareharbor.com/embeds/book/bellesguardgaudi/"]').each(function() {
            var newHref = $(this).attr('href') + '&language=' + languageParam;
            $(this).attr('href', newHref);
        });
    }
});
</script>
content_copyCOPY