• Resolved kardoo

    (@kardoo)


    I want my website to read a cookie then change the language but I don’t know how TranslatePress is programmed how do I go about doing so?

    if(isset($_COOKIE['lango']) && $_COOKIE['lango']== "span" ) {
    			
    			//code to change language here			   
         }

    I want to type something in the if statement that would be the equivalent of hovering your mouse on the language dropdown menu and clicking Spanish.

Viewing 1 replies (of 1 total)
  • Plugin Support Alex

    (@alexcozmoslabs)

    If you want to change from a language to another, through PHP, you need just to redirect to that language:

    $trp = TRP_Translate_Press::get_trp_instance();
    		$url_converter = $trp->get_component( 'url_converter' );
    		$code = "en_US";
    		$current_url_in_english = esc_url( $url_converter->get_url_for_language($code, false, '') );
    		wp_redirect( $current_url_in_english );
    		exit;
    
Viewing 1 replies (of 1 total)

The topic ‘How to change language through php?’ is closed to new replies.