How to setup "translations" in a virtual page?


I have built a route for data coming from an API to display it as a virtual page. So far so good with Page::factory for adding slug, template, contents, … .

But now I’ld like to know how I have to setup the translations from it. As far as I see, it should be a Collection. Is there any tips on how I have to set this up so my language-switch-navigation works?



like this?


I can’t get this to work. Isn’t ContentTranslation meant for dealing with the file where the translated content lives?

I am somehow unable to hook the translated content to the virtual page to make the language switch nav (via $page->url($language->code()) in a loop over the available languages - in the template) to work.


Each item in $page->translation() looks like this:

  public 'code' => string 'fr' (length=2)
  public 'content' => 
    array (size=0)
  public 'exists' => boolean false
  public 'slug' => null