# Copy content to translated page

**URL:** https://forum.getkirby.com/t/copy-content-to-translated-page/23847
**Category:** Questions
**Tags:** v3
**Created:** [November 2, 2021, 11:47pm UTC](https://forum.getkirby.com/t/copy-content-to-translated-page/23847 "2021-11-02T23:47:17Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![sigi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sigi/32/9998_2.png) [@sigi](https://forum.getkirby.com/u/sigi)
#### Post date: [November 2, 2021, 11:47pm UTC](https://forum.getkirby.com/t/copy-content-to-translated-page/23847/1 "2021-11-02T23:47:17Z")

</div>

Hi there,

I am wondering, if there is a way to copy all contents of a page to its translation from within the panel. Maybe someone knows a way?

Thank you very much in advance!

Sigi

---

<div class="post-metadata">

### Author: ![moonwalk](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@moonwalk](https://forum.getkirby.com/u/moonwalk)
#### Post date: [November 3, 2021, 7:01am UTC](https://forum.getkirby.com/t/copy-content-to-translated-page/23847/2 "2021-11-03T07:01:34Z")

</div>

Maybe with a Janitor button and a custom job: [Janitor | Kirby CMS](https://getkirby.com/plugins/bnomei/janitor). Make sure not to overwrite existing translations, though.

---

<div class="post-metadata">

### Author: ![sigi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sigi/32/9998_2.png) [@sigi](https://forum.getkirby.com/u/sigi)
#### Post date: [November 3, 2021, 11:24am UTC](https://forum.getkirby.com/t/copy-content-to-translated-page/23847/3 "2021-11-03T11:24:02Z")

</div>

Thank you, I will look into that.

---

<div class="post-metadata">

### Author: ![sigi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sigi/32/9998_2.png) [@sigi](https://forum.getkirby.com/u/sigi)
#### Post date: [November 13, 2021, 2:11pm UTC](https://forum.getkirby.com/t/copy-content-to-translated-page/23847/4 "2021-11-13T14:11:40Z")

</div>

I think, the solution with the Janitor Plugin works, but I have issues with achieving what I want with my code. Maybe someone sees what’s wrong here?

```auto
'bnomei.janitor.jobs' => [
    'copy' => function (Kirby\Cms\Page $page = null, string $data = null) {
        if ($page === null) {
          $page = site()->index(true)->findByID($data); 
        }
        $languages = kirby()->languages();
        $content = $page->text();
        $translation = page($page->uri($languages->not(kirby()->language())->first()->code()));
        $translation = $translation->update(['text' => $content]);
        return [
            'status' => 200,
            'label' => 'Kopiert.',
        ];
    },
  ],

```

---

<div class="post-metadata">

### Author: ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)
#### Post date: [November 13, 2021, 2:17pm UTC](https://forum.getkirby.com/t/copy-content-to-translated-page/23847/5 "2021-11-13T14:17:46Z")

</div>

> [@sigi](#):
>
> ```auto
> $translation = page($page->uri($languages->not(kirby()->language())->first()->code()));
> $translation = $translation->update(['text' => $content]);
> 
> ```

A translation doesn’t exist as a separate page. You update a translation by updating the page and passing the language code as second parameter:

For example, update all non-default languages:

```auto
$languages = kirby()->languages()->not(kirby()->defaultLanguage());
foreach ( $languages as $language ) {
  $page->update(
    [
      'text' => $content
    ], 
    $language->code()
  );
}

```

---

<div class="post-metadata">

### Author: ![sigi](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/sigi/32/9998_2.png) [@sigi](https://forum.getkirby.com/u/sigi)
#### Post date: [November 13, 2021, 2:46pm UTC](https://forum.getkirby.com/t/copy-content-to-translated-page/23847/6 "2021-11-13T14:46:19Z")

</div>

Thank you very much, that’s it and also explains a lot.  
Is there a way to mark both of your answers as solutions?

---

<div class="post-metadata">

### Author: ![texnixe](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/texnixe/32/5754_2.png) [@texnixe](https://forum.getkirby.com/u/texnixe)
#### Post date: [November 13, 2021, 3:02pm UTC](https://forum.getkirby.com/t/copy-content-to-translated-page/23847/7 "2021-11-13T15:02:49Z")

</div>

> [@sigi](#):
>
> Is there a way to mark both of your answers as solutions?

No, there is always only one solution here.
