---
title: "Janitor Integration"
description: "Wrap a CLI translation command in a Janitor button so editors can trigger it from the Panel without shell access."
canonical_url: "https://kirby.tools/docs/content-translator/cli-automation/janitor"
---

# Janitor Integration

> Wrap a CLI translation command in a Janitor button so editors can trigger it from the Panel without shell access.

While you can run Kirby commands from the CLI, you can also create a custom [Kirby Janitor](https://github.com/bnomei/kirby3-janitor) command to translate content and run it from the Panel.

<preview alt="Content Translator section with Janitor command" height="96" src="/img/kirby-content-translator-section-janitor.png" width="1140">



</preview>

## Blueprint Field

Create a field in your blueprint that triggers the Janitor command:

```yaml [fields/janitor-translate-files.yml]
label: Translate Files Metadata
type: janitor
command: janitor-translate-files --language de
```

## Command

Create the Janitor command in your `site/commands` folder:

<code-collapse>

```php [site/commands/janitor-translate-files.php]
use Bnomei\Janitor;
use Kirby\CLI\CLI;

return [
    'description' => 'Translates all files metadata of a specific page.',
    'args' => [
        'language' => [
            'longPrefix' => 'language',
            'description' => 'The target language to translate the content to.',
            'required' => true
        ]
    ] + Janitor::ARGS,
    'command' => static function (CLI $cli): void {
        $kirby = $cli->kirby();
        $defaultLanguage = $kirby->defaultLanguage()->code();
        $targetLanguage = $cli->arg('language');
        $page = $kirby->page($cli->arg('page'));

        foreach ($page->files() as $file) {
            $translator = $file->translator();
            $translator->copyContent($targetLanguage, $defaultLanguage);
            $translator->translateContent($targetLanguage, $targetLanguage, $defaultLanguage);
        }

        Janitor::singleton()->data($cli->arg('command'), [
            'status' => 200,
            'message' => 'Files translated successfully!'
        ]);
    }
];
```

</code-collapse>

The command receives the current page context from Janitor, making it easy to create page-specific translation buttons in your blueprints.

---

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