• Hello, I would like to find a way to change my website’s language based on the cookie that I have made it save.
    I have a custom plugin that saves the language cookies like this:

    function aws_set_language_cookie() {
    
        //To save the language in a cookie
        
        $current_language = get_locale();
        
        if ($current_language == "es_ES") {
            $result = setcookie('lang', $current_language, time() + (30 * DAY_IN_SECONDS), '/');
    
        } else {
            $result = setcookie('lang', $current_language, time() + (30 * DAY_IN_SECONDS), '/');
        }
    
        //To read the cookie and change the language based on the cookie
        
        if (isset($_COOKIE['lang']) && $_COOKIE['lang'] == "es_ES") {
            //need code to change website language to spanish here
        }
    }

    How do I change the language to Spanish inside the last if statement?

    The plugin I use to change my website’s language is called TranslatePress

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How do I change language’ is closed to new replies.