Hello,
I have two routes which generates a json structure.
One route is for french the other one for english.
The json datas are coming from input written into the panel by the user.
[
'pattern' => 'fr/myapi/subprog-items.json',
'language' => 'fr',
'action' => function () {
header('Content-type: application/json; charset=utf-8');
$json = array();
foreach (site()->residency()->toStructure() as $residencies) {
foreach ($residencies->subprog()->toStructure() as $subprog) {
$json[] = array(
'title' => (string)$subprog->subprogtitle(),
);
}
}
return Json::encode($json);
}
],
[
'pattern' => 'en/myapi/subprog-items.json',
'language' => 'en',
'action' => function () {
header('Content-type: application/json; charset=utf-8');
$json = array();
foreach (site()->residency()->toStructure() as $residencies) {
foreach ($residencies->subprog()->toStructure() as $subprog) {
$json[] = array(
'title' => (string)$subprog->subprogtitle(),
);
}
}
return Json::encode($json);
}
],
I would like to get the adress of each routes depending on the selected language into a query field.
With something like that:
subprog:
label: subprog
type: select
width: 1/4
options: api
api:
url:
fr: http://localhost:8888/00-AR/fr/myapi/subprog-items.json
en: http://localhost:8888/00-AR/en/myapi/subprog-items.json
text: "{{ item.title }}"
value: "{{ item.title }}"
Is this possible or should I try to manage the language display via the routes?
Thanks a lot for any suggestions.