Auto creates a translator from a translator plugin definition.
array $definition: The definition of a translator plugin.
function tmgmt_translator_auto_create(array $definition) {
$plugin = $definition['id'];
if (!Translator::load($plugin)) {
$translator = Translator::create([
'name' => $plugin,
'plugin' => $plugin,
'remote_languages_mappings' => array(),
'label' => $definition['label'],
'description' => (string) $definition['description'],
]);
// Append default settings from the translator plugin definition.
$translator
->setSettings($translator
->getPlugin()
->defaultSettings());
$translator
->save();
}
}