Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
If you will search your site in google search and pass throught search result link you won't be redirected to correct language.
This is because at line 147 you check HTTP_REFERER with strpos function, and it returrn 108, because google store redirect address in url param.
I change this line
isset($_SERVER['HTTP_REFERER']) && strpos($_SERVER['HTTP_REFERER'], $_SERVER['SERVER_NAME'])
to
isset($_SERVER['HTTP_REFERER']) && preg_match('#http(?:s)?://'.$_SERVER['SERVER_NAME'].'#', $_SERVER['HTTP_REFERER'])
and now all looks work good.