MutationDigitale / craft3-translate

Craft CMS plugin for static translations in CP
Other
12 stars 7 forks source link

Translations admin plugin for Craft CMS

This plugins adds a control panel interface for your clients to edit your static translations for each language side by side.

Screenshot

Features

Requirements

This plugin requires Craft CMS 4.0.0 or later.

Installation

Install the plugin via the Plugin Store or by command line:

composer require mutation/translate
php craft install/plugin translations-admin

You can now edit your translations in the control panel /admin/translations-admin.

Permissions

You have special permissions for the Translations admin plugin:

Settings

You can either go the settings page or create a file translations-admin.php in your config directory.

Config file example:

<?php

return [
    'pluginName' => 'Translations',
    'categories' => [
        ['category' => 'site'],
        ['category' => 'app']
    ],
    'addMissingTranslations' => false,
    'addMissingSiteRequestOnly' => false
];

GraphQL

Query static messages this way:

{
  staticMessages(language:["en-CA", "fr-CA"], category: ["site", "app"]) {
    key
    message
    language
    category
    dateCreated
  }
}

Events

You can use these custom events in your plugin or module to do any actions after translations are added, saved or deleted (example: empty the cache):

use mutation\translate\services\MessagesService;

Event::on(MessagesService::class, MessagesService::EVENT_AFTER_SAVE_MESSAGES, function (Event $e) { ... });
Event::on(MessagesService::class, MessagesService::EVENT_AFTER_ADD_MESSAGE, function (Event $e) { ... });
Event::on(MessagesService::class, MessagesService::EVENT_AFTER_DELETE_MESSAGES, function (Event $e) { ... });