Skip to content

Kirby 4.1.2

Translations

Translations are registered with the translations extension. It takes an array of languages, where each language consists of an array of key/value pairs.

/site/plugins/your-plugin/index.php
Kirby::plugin('your/plugin', [
    'translations' => [
        'en' => [
            'your.plugin.export' => 'Export',
        ],
        'de' => [
            'your.plugin.export' => 'Exportieren',
        ]
    ]
]);

You can now use these translations in your plugin, for example in a panel field:

/site/plugins/your-plugin/index.js
panel.plugin('your/plugin', {
    fields: {
        export: {
            template: "<k-button>{{ $t('your.plugin.export') }}</k-button>"
        }
    }
});

The translation variables are global, it is therefore recommended to prefix them with your plugin name to avoid issues when the same name gets used multiple times.

It is however also possible to register "global" translations without prefix from a plugin if that's what you need.