createChild with non-default language and translate: false

I believe I found an issue with the behavior of $page->createChild() (or any way to programmatically create a page) and translate: false fields in a multi-language setup.

Assume the available languages are de (default) and en. Also, there is an order.yml page blueprint like this:

title: Order
fields:
  order_id:
    label: ID
    type: text
    translate: false

Now when the current language is en (non-default) and a new order page should be created with:

$orders->createChild([
  'slug' => 'myorder',
  'template' => 'order',
  'content' => [
    'title' => 'my order',
    'order_id' => '123456',
  ],
]);

a new order.en.txt is created which only includes the Title. The Order_id field is lost, since no order.de.txt is created which would normally include all the fields with translate: false. My expected behavior here would be that both order.en.txt and order.de.txt should be created.

I found that you can set translations in the arguments to createChild but I didn’t understand how that works (is it documented?). Maybe that would be a way to make this work in any language. Currently I’m working around this issue by manually setting the current language to the default before createChild() and then resetting the language afterwards.

1 Like

I think I’ve seen this issue before, but could not find a bug report on GitHub, nor can I find the topic here.