Once the linked PR is merged, update to version 1.9.0 of the plugin. Something like this should then work:
In the routes:
[
"pattern" => "generate-static-site/(:any)/page:(:num)",
"action" => function ($pageId, $pageNum) {
$params = kirby()
->request()
->url()
->params();
$params->page = $pageNum;
$html = page($pageId)->render();
$params->page = null; // reset the param after rendering the page
return $html;
},
]
and in your example you'd switch the custom routes so they are like this:
$myRoutes[] = [
"path" => "de/notes/$i",
"page" => "notes",
"route" => "generate-static-site/notes/page:$i",
"languageCode" => "de",
];
$myRoutes[] = [
"path" => "en/notes/$i",
"page" => "notes",
"route" => "generate-static-site/notes/page:$i",
"languageCode" => "en",
];
The new thing here is that you can now add a page to the custom route so that when rendering the route there is an additional page context which is used when rendering the pagination links.
You will still have to manually reformat the pagination links from page:x to /x in your template, but the base URL should now work and there should be no mixup of languages.
You can also completely skip adding a "proxy" route and instead just render the custom routes without pointing to a route. You can then add the page as a template variable by using the data attribute in the custom routes.
Example:
$myRoutes[] = [
"path" => "de/notes/$i",
"page" => "notes",
"languageCode" => "de",
"data" => ["pageNum" => $i]
];
$myRoutes[] = [
"path" => "en/notes/$i",
"page" => "notes",
"languageCode" => "en",
"data" => ["pageNum" => $i]
];
Then, in your template you can get the current page number like this:
$pageNumber = $pageNum? param('page')? 1;
Then, when calling ->children()->paginate( just pass it as the second argument to set the current page number. Documentation: https://getkirby.com/docs/reference/objects/cms/pages/paginate