ClarkAdams
ClarkAdams

Reputation: 45

Can't set new google translate cookie value on iOS devices

I am making a prototype and a big part of the site is being presented in different languages. I found this video which worked beautifully on my desktop browsers and android device. But when trying it on my iOS devices (with Safari and chrome) the cookie "googtrans" can only be set once then it keeps that value. Here is the code setting the cookie:

    $(".lang-selections li").click(function(){
    switch(this.id) {
        case ("langEng"):
            $.cookie("googtrans", "/en/en");
            location.reload(false); 
            break;
        case ("langNor"):
            $.cookie("googtrans", "/en/no");
            location.reload(false);
            break;
        case ("langSwe"):
            $.cookie("googtrans", "/en/sv");
            location.reload(false);
            break;
        case ("langDan"):
            $.cookie("googtrans", "/en/da");
            location.reload(false);
            break;   
        default:
            $.cookie("googtrans", "/en/en");
        }
    })

Thanks in advance for the help!

/Manfred

Upvotes: 0

Views: 1140

Answers (1)

himansu
himansu

Reputation: 1917

In google chrome there are two cookie generate for googtrans so while create that you must set both of these with domain.Here i set cookie by javascript also set by jQuery also.

function ChnageLang(value)//This function call when dropdown menu changes
{
    createCookie('googtrans','/auto/'+value,1,'');//generate cookie path www.mydomain.com
    createCookie('googtrans','/auto/'+value,1,'mydomain.com');//generate cookie path .mydomain.com
}
function createCookie(name, value, days, domain){
if (days){
    var date = new Date();
    date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
    var expires = "; expires=" + date.toGMTString();
    } 
    else{var expires = "";}
    document.cookie = name + "=" + value + expires + "; domain=" + domain + "; path=/";
}

Upvotes: 2

Related Questions