I don't know much about "Polylang" plugin but upon searching "pll_get_post" might do it.
replace your code with this code and "1" with your thank you page post id.
add_action( 'wp_footer', 'mycustom_wp_footer' );
function mycustom_wp_footer() {
if ( function_exists( 'pll_get_post' ) ) {
// Get the translated Thank You page URL
$page_id = 1; // Replace with the actual Thank You page ID in default language
$new_thank_you_url = get_permalink( pll_get_post( $page_id ) );
}
?>
<script>
document.addEventListener( 'wpcf7mailsent', function( event ) {
location = "<?php echo esc_url( $translated_thank_you_url ); ?>";
}, false );
</script>
<?php
}
Here is the link if you want to study about the function
https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/