samnabi
1
I know that you can direct people to a specific language version of a page using routes, but Iβm hitting a speedbump trying to insert custom language variables.
Nothing gets written when I do something like this:
array(
'pattern' => 'url/path/goes/here',
'method' => 'POST',
'action' => function() {
echo l::get('something');
return true;
}
),
samnabi
2
I can set the detected language with a hack like this:
array(
'pattern' => 'url/path/goes/here',
'method' => 'POST',
'action' => function() {
// Set detected language
site()->visit('home', (string) site()->detectedLanguage());
site()->kirby->localize();
// Write the string
echo l::get('something');
return true;
}
),
It appears that site()->detectedLanguage()
gives a value, but site()->language()
is still blank at this pointβ¦
1 Like