---
title: "Single Page"
description: "Copy and translate a single page’s content to any target language from the command line, without opening the Panel."
canonical_url: "https://kirby.tools/docs/content-translator/cli-automation/single-page"
---

# Single Page

> Copy and translate a single page’s content to any target language from the command line, without opening the Panel.

The most common use case is to copy the content from the default language to a secondary language and then translate the duplicated content to the target language.

## Prerequisites

Install the [Kirby CLI](https://github.com/getkirby/cli) and create a `site/commands` folder if it does not exist yet.

## Command

<code-collapse>

```php [site/commands/translate-page.php]
use Kirby\CLI\CLI;

return [
    'description' => 'Translates the content of a specific page.',
    'args' => [
        'language' => [
            'description' => 'The target language to translate the content to.',
            'defaultValue' => 'de'
        ]
    ],
    'command' => static function (CLI $cli): void {
        $kirby = $cli->kirby();
        $defaultLanguage = $kirby->defaultLanguage()->code();
        $targetLanguage = $cli->arg('language');

        $siteChildren = $kirby->site()->children();
        $titles = array_map('strval', $siteChildren->pluck('title'));
        $input = $cli->radio(
            'Which page should be translated?',
            $titles
        );
        $response = $input->prompt();
        $cli->success('Selected page: ' . $response);

        $page = $siteChildren->findBy('title', $response);
        if ($page === null) {
            $cli->error('Page "' . $response . '" not found.');
            return;
        }

        $translator = $page->translator();
        $translator->copyContent($targetLanguage, $defaultLanguage);
        $translator->translateContent($targetLanguage, $targetLanguage, $defaultLanguage);
        $translator->translateTitle($targetLanguage, $targetLanguage, $defaultLanguage);
        // $translator->translateSlug($targetLanguage, $targetLanguage, $defaultLanguage);

        $cli->success('Successfully translated ' . $page->id());
    }
];
```

</code-collapse>

## Usage

```bash
# Translate the content of a specific page to German
kirby translate-page de
```

---

Every page of this site as Markdown: <https://kirby.tools/sitemap.md>
