'routes' => [
[
'pattern' => '(:any)',
'language' => 'en',
// 'method' => 'GET',
'action' => function ($language, $any) {
//... some code here
}
],
[
'pattern' => '(:any)',
'language' => 'en',
'method' => 'POST',
'action' => function () {
//... some code here
}
],
]
Do I have to write everything like this instead?
[
'pattern' => '(:any)',
'language' => 'en',
'method' => 'GET|POST',
'action' => function () {
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
//... some code here
} else {
//... some code here
}
}
],
It is too long to describe the exact error that occurs here (among other things, it is about a uniform form with AJAX, where the error message is not translated).
If you use one language with and one without a language code, then you need separate routes or you have to use if statements inside your route to check if the variable is a language code or not.
It works better when both languages use a language code.