Hello,
I have being testing this code and have problem with the IF function…
I want the page if it’s in french, to redirect to the french home page and if it’s in english, to redirect to the english homepage.
Here’s my code and please help!
Thank you!
PS: I have a welcome page that redirects after a time delay to the homepage
#redirect #multilingual #if #url
import wixLocation from ‘wix-location’;
import wixWindow from ‘wix-window’;
$w.onReady( function () {
//TODO: write your page related code here…
setTimeout( function () {
if (wixWindow.referrer !==‘https://www.gmongrut.com/?lang=fr’)
{
wixLocation.to(‘https://www.gmongrut.com/home?lang=fr’);
}
if (wixWindow.referrer !==‘https://www.gmongrut.com’)
{
wixLocation.to(‘https://www.gmongrut.com/home’);
}
}, 2500);
});
@yoav-wix
@yisrael-wix
Please help me out on this one! I appreciate! 
To navigate to a local page:
wixLocation.to(“/home”);
or
wixLocation.to(“/home?lang=fr”);
See the wix-location.to() API for more information.
Hello @Yisreal (Wix)
With this code, page refreshes it self over and over again - forever. Do you know what am I doing wrong here? Thank you for your time and dedication.
import wixLocation from 'wix-location';
import wixWindow from 'wix-window';
$w.onReady(function () {
setTimeout(function () {
switch (wixWindow.browserLocale) {
case 'pl-PL':
case 'pl':
wixLocation.to('https://www.pamoperations.com/?lang=pl');
break;
default:
wixLocation.to('https://www.pamoperations.com/?lang=en');
break;
}
}, 6500);
});
Kind regards,
Paul
I’m also trying use the same code as Paul and the site keeps refreshing, is there something missing in the code above? Also is the timeout necessary?
@Yoav (Wix)
@Yisrael (Wix)
Can you please help on the above?