How is it possible to create a new translated page programmatically

Hi, I want to use the default language page (home.en.txt), translate the content into an other language ( zh) and store it as new file (home.zh.txt) in the same folder.

I found: #creating-pages-programmatically, checked the source code and found

// always create pages in the default language

So is there a change to create translation files programmatically except changing the source code and adding language as $props?

I would love to get some hints where I can start digging.
Stinkstiefel

If the page already exists in the default language, you can create a translation with $page->update(), e.g.

$page->update([
  'text' => 'Lorem ipsum'
], 'de');

Apart from the data array, pass the language code for the translation as second argument.

1 Like

Works fine - perfect - awesome…