How to Automatically Change Website Primary Language Based on User Location

I have a multilingual Wix site with both English and Chinese versions. I am currently using the following code to fetch the user’s location, which successfully retrieves the country name, country code, and city.

I would like to automatically change the website’s primary language based on the user’s location as soon as the site loads.

Could anyone advise on the best way to achieve this within Wix, preferably using the Wix Velo or Wix SDK or any recommended approach?

Note: using below line of code is not working

wixWindowFrontend.multilingual.currentLanguage = "zh";

as it change the website language to Chinese automatically every time I tried to set it as English

Thanks in advance for your help!

export function getCurrentCountry() {
    return fetch("https://api.db-ip.com/v2/free/self", {
        method: "get"
    })
    .then(response => {
        if (response.status === 200) {
            return response.json();
        } else {
            throw new Error("Request Failed");
        }
    })
    .then(data => {
        console.log(data);
        return {
            countryCode: data.countryCode, 
            countryName: data.countryName 
        };
    })
    .catch(error => {
        console.error("Error fetching country data:", error);
        return null;
    });
}