In a multilanguage site I’m using a gateway plugin to switch context depending on URL. The language switching works, but in the error log I get an error message each time I load a page in the default (web) context:
Undefined array key "cultureKey"
All contexts have a cultureKey set.
The URL for the default language is just domain.se/ and the domains for the other languages are domain.se/en and domain.se/de.
The gateway plugin looks like this:
if($modx->context->get('key') != "mgr"){
/* grab the current langauge from the cultureKey request var */
switch ($_REQUEST['cultureKey']) {
case 'en':
/* switch the context */
$modx->switchContext('English');
break;
case 'de':
/* switch the context */
$modx->switchContext('Deutsch');
break;
default:
/* Set the default context here */
$modx->switchContext('web');
break;
}
/* unset GET var to avoid
* appending cultureKey=xy to URLs by other components */
unset($_GET['cultureKey']);
}
PHP 8.2.10
MODX 3.0.4-dev