Is there a way to reload the panel page after switching language?

Hi there,
I’m wondering if there is a way to reload the panel page after switching language.
In few words I have a plugin which runs detecting variables in querystring (_language in particular)

Could you provide some more information, I don’t quite get it. If you are doing anything with JavaScript, you can make your script reload the page.

I’m doing it with php, I’m into a plugin. When I change language in panel, the whole panel loads itself with asyncronous call and doesn’t take my querystring parameter…
I need to refresh the entire page

Could you maybe provide your plugin code?

thanks @distantnative

$querystring = $_SERVER["QUERY_STRING"];
kirby()->set('option', 'panel.stylesheet', u() . '/panel-environment.css?'.$querystring);
		'pattern' => 'panel-environment.css',
		'action' => function() {
			header("Content-type: text/css; charset: UTF-8");
			$language = isset($_GET['_language']) ? $_GET['_language'] : "EN";
			$csse_path = kirby()->roots()->plugins() . DS . 'panel-environment' . DS . 'assets' . DS . 'css' . DS . 'panel-environment.css';
			$csse = file_get_contents($csse_path);
			$csse = str_replace(
					c::get('plugin.panel.environment', 	'DEV'),
			echo $csse;

I’m using it for environment and language detection

You can’t trigger the Panel to reload from the server. For that to work, you need some JS that listens to the language switch event and then makes a request to the server. And to include custom JS in the Panel, you need a Panel extension (field) that does this.

In fact, since you are using code from the Panel brand plugin, you would have to somehow merge that with the functionality of the Panel flags plugin:

are there any documented JS samples on how to listens language switch event?

No, not that I’m aware of. But there is that language toggle and you can listen when the user clicks on that and selects a language that is different from the currently selected value.

For knowledge, the affected file is located in:

  <a id="languages-toggle" class="languages-toggle" data-dropdown="true" href="#languages">
    <span><?php __($language->code()) ?></span>

  <nav id="languages" class="dropdown dropdown-left">
    <ul class="nav nav-list dropdown-list">
      <?php foreach($languages as $lang): ?>
        <a href="?_language=<?php echo $lang->code() ?>"><?php __(strtoupper($lang->code())) ?></a>
      <?php endforeach ?>