Multilanguage search


I have search and multilanguage on my website, however there is one thing I don’t understand. When I use the search as e.g. an English user, I search in the English text files. However when I get the results of the search and I’m on the page where I listed them and I choose another language e.g. German, the query disappears from the url.

$page->url($language->code()) <-- this is the code what I use for changing the language, but I don’t know what should I write after the code(), because I would like to give back the query to the end of the url.

From http://localhost:8000/search?q=asd I get http://localhost:8000/de/search but I would like to get http://localhost:8000/de/search?q=asd

Thank you for your answers!

What method do you use for your search form? POST? If you change to GET, that should fix it.

I use get method. But I’m thinking about there is a problem with the multilingualism. Because I use this code :

 <?php foreach($kirby->languages() as $language): ?>
      <a class="<?php e($kirby->language() == $language, 'active') ?>" href="<?= $page->url($language->code())?> " hreflang="<?php echo $language->code() ?>"> <?=html($language->name()) ?>
  <?php endforeach ?>

And it is opening the basic search page with the language code. But the query disappears.

this is the search:

Where’s the point of using the same search for both languages, anyway?

If you change the page, a new request is made to the server and you would have to store your search in the session or something like that to preserver your search.

Thank you for your answer! Finally I could made it. I didn’t think about how to store the search.

I really appreciate your help in resolving the problem.