Trying to get it to correctly display the language with the alias in the URL

Hello community

I have a form that I want that taking the alias of the taxonomy create a URL path and take me to it. The submit has two options, show the default URL that does it correctly and the second that is when there is a chosen taxonomy, which is the one that fails me. It is assumed that passing to “getAliasByPath” as the second parameter the language should put it in the URL but it does not. So I’m trying to add the language to the URL by detecting it from the page itself and then concatenating it to the URL, this does it right, the first time, if in the dropdown you start navigating through the options, start duplicating the language on the route and the second time stop showing it well. I have looked at 1000 post and I have run out of ideas tired of trying things that do not work. Can you think of a way to solve it?

namespace Drupaldishes_dropdownForm;

use DrupalCoreFormFormBase;
use DrupalCoreFormFormStateInterface;
use DrupalCoreRoutingTrustedRedirectResponse;
use DrupalCoreUrl;
use DrupalComponentUtilityUrlHelper;

class DishesDropdownForm extends FormBase {

    public function getFormId() {
        return 'dishes_dropdown_form';

    public function buildForm(array $form, FormStateInterface $form_state) {
        $maxlength = 250;
        // We take the values of the "array" "dish_type" and then collect them in the form and show them as they are collected.
        $dish_type = Drupal::entityTypeManager()->getStorage('taxonomy_term')->loadTree('dish_type', $parent=0, $max_depth=NULL, $load_entities=FALSE);
        $dish_types = array();
        foreach ($dish_type as $dish_type) {
            $dish_types[$dish_type->tid] = $dish_type->name;
        $dish_types[0] = '--Mostrar todos los platos--';
        $default_dish = array_flip($dish_types);
        $form['dish_dropdown'] = array(
            '#type' => 'select',
            '#options' => $dish_types,
            '#chosen' => true,
            '#multiple' => false,
            '#maxlength' => $maxlength,
            '#default_value' => $default_dish,
        $form['submit'] = [
            '#type'  => 'submit',
            '#value' => $this->t('Ir al tipo de plato'),
            '#weight' => 50,
        return $form;

    public function submitForm(array &$form, FormStateInterface $form_state) {
        // We bring the id of the taxonomy.
        $id = reset($form_state-> getValues('dish_dropdown'));
        //  If the value is 0 (default value) we show all the dishes.
        if ($id == 0) {
            $url = Url::fromRoute('');
        } else {
            // We generate the url according to the option of the selected array
            $aliasManager = Drupal::service('path.alias_manager');
            // The second argument to getAliasByPath is a language code such as "en" or LanguageInterface::DEFAULT_LANGUAGE.
            $alias = $aliasManager->getAliasByPath('/taxonomy/term/' . $id);
            // We launched the url
            $url = new TrustedRedirectResponse($alias);
                -> setResponse($url);
Drupal version: