How to save the same content in all language files at once?

When i save a page in the panel, i would like to save the current content of that page to all of it’s language files. independently of the current language.

In the following simplified page model, i am overwriting the writeContent-Method.
I tried $this-save() with a different language, but that leads to an endless loop, cause writeContent will be called again and again…

i also tried to call parent::writeContent with ‘en’. That works, but that seems a bit hackisch.
Does anyone maybe knows a good/better solution for that edge case?


class MessagePage extends Page
    public function writeContent(array $data, string $languageCode = null): bool
        if ($id = Db::insert('message', [
            'slug' => $this->slug(),
        ])) {
            // $$data, 'en', true); -> endless loop
            $enPage = parent::writeContent($data, 'en');
            return parent::writeContent($data, $languageCode);
        } else {
            throw new Exception('Error');

save() cannot work because internally, it calls writeContent(), that’s why you are running into an endless loop.

Not aware of a better way to achieve this, actually. Must say, I don’t quite get the purpose of saving the same content in multiple languages.

its a really special case, where some pages in a multilanguage-setup, should be singleLanguage by the help of mullema/k3-panel-view-extended
To avoid editor-inputs in the wrong language, we would like to always save that page, independently of the current language to all language-files. It works like above, but thought it could be better.