Hide Lightbox from multilingual site

Hi!
I was looking into setting up a Lightbox for the English version of my page, but hiding it from the Swedish version. I’ve been looking around the forums to see if anyone has an answer on how to do that, unfortunately I couldn’t find a solution to my problem.

Does anyone know if this is possible, and if so, how?

// Elsa

Hi @hemsidan

First, I need to know how do you intend to open the lightbox, is it automatically, or by user interaction?

Either ways, you need to check the current language first, then show the lightbox if the current language is the English version.

import wixWindow from 'wix-window';

const language = wixWindow.multilingual.currentLanguage;

Here’s how to open it automatically if the current language is English.

$w.onReady(() => {
    if (language === 'en') {
        wixWindow.openLightbox('Lightbox Name');
    }
})

Open it by a trigger, e.g. on click.

$w.onReady(() => {
    $w('#openLightboxBtn').onClick(() => {
        wixWindow.openLightbox('Lightbox Name');
    })
})

Hope this helps~!
Ahmad

Thank you so much for the quick answer Ahmad. It works perfectly :slight_smile:

// Elsa

You’re welcome :blush: Happy to help

Hey Ahmad, very great! Thank you. It generally also works with me.

But what if one wants to have a delay before the lightbox appears, say 45 seconds after the page has loaded.