mutation / translate
Translate messages in the control panel
Installs: 56 581
Dependents: 1
Suggesters: 0
Security: 0
Stars: 12
Watchers: 3
Forks: 9
Open Issues: 9
Type:craft-plugin
Requires
- php: ^8.0.2
- craftcms/cms: ^4.0.0|^5.0.0
- phpoffice/phpspreadsheet: ^1.22.0
- dev-master
- v4.x-dev
- 4.1.1
- 4.1.0
- 4.0.2
- 4.0.1
- 4.0.0
- 4.0.0-beta.1
- v3.x-dev
- 3.2.3
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.0
- 3.0.4
- 3.0.3
- 3.0.2
- 3.0.1
- 3.0.0
- 3.0.0-beta.1
- v2.x-dev
- 2.7.1
- 2.7.0
- 2.6.1
- 2.6.0
- 2.5.3
- 2.5.2
- 2.5.1
- 2.5.0
- 2.4.8
- 2.4.7
- 2.4.6
- 2.4.5
- 2.4.4
- 2.4.3
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.6
- 2.3.5
- 2.3.4
- 2.3.3
- 2.3.2
- 2.3.1
- 2.3.0
- 2.2.1
- 2.2.0
- 2.1.7
- 2.1.6
- 2.1.5
- 2.1.4
- 2.1.3
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.7
- 2.0.5
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.7.1
- 1.7.0
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.9
- 1.4.8
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.7
- 1.1.6
- 1.1.5
- 1.1.4
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.18
- 1.0.17
- 1.0.16
- 1.0.15
- 1.0.14
- 1.0.13
- 1.0.12
- 1.0.11
- 1.0.10
- 1.0.9
- 1.0.8
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-dependabot/npm_and_yarn/axios-1.8.2
- dev-develop
- dev-old-version
This package is auto-updated.
Last update: 2025-03-07 15:17:45 UTC
README
This plugins adds a control panel interface for your clients to edit your static translations for each language side by side.
Features
-
Add, edit or delete translations in the Control Panel with each language side by side.
-
Choose a category, filter by missing translations, search by keywords and sort by key/date.
-
Export all or a subset of your translations to a CSV file and import it back after translators worked on it.
-
Translations will be kept inside your database instead of PHP files for a better workflow.
-
Optionally, missing translations are automatically added to the database when a page is visited.
-
Ability to parse your twig templates or migrate from your existing PHP translations (and export it back to PHP files).
-
GraphQL support to query your translations.
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:
- Save translations
- Add translations
- Delete translations
- Update translations
- Export translations
- Import translations
- Use translations utilities
- Change translations settings
Settings
You can either go the settings page or create a file translations-admin.php
in your config
directory.
- Plugin Name: How the plugin should be named in the CP
- Categories: Choose the source message categories you want to have in your database and control panel.
- Add missing translations: Controls whether missing translations are automatically added to the database when a page is visited.
- Add missing translations for site request only: Controls whether missing translations are only added when the request is from the site.
- Excluded Messages: Messages that should not be added to the database, identified by the start of the string (basic matching, no regex — see example).
Config file example:
<?php return [ 'pluginName' => 'Translations', 'categories' => [ ['category' => 'site'], ['category' => 'app'] ], 'addMissingTranslations' => false, 'addMissingSiteRequestOnly' => false, 'excludedMessages' => [ 'Submission triggered for', 'Submission marked as spam' ] ];
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) { ... });
Methods
You can create a new translation programmatically (in migrations or otherwise):
use mutation\translate\Translate as TranslatePlugin; ... TranslatePlugin::getInstance()->messages->addMessage("Lorem ipsum", "site");
The second parameter is the category (site, app, etc.)