Always a risk when you start changing internal classes, if the URI class changes it's logic, or the processing logic changes, you have problems like this.
If you look at the processing logic, the application bootstrap is called from index.php, before the request is forged, so at that time you don't have a valid URI object yet.
If you want to do it this way, it's better to manipulate the $_SERVER entry itself, extract the first URL segment, check if it is a valid language, and if s, update the $_SERVER entry with a new URL.
Alternatively, you can try to bring the URI parsing forward, using
$uri = new \Uri($this->input->uri());
Which forces input to start parsing the URL in $_SERVER.