private function MergeTranslationsForm::addTranslation in Merge translations 8
AddTranslation.
Parameters
string $langcode: Langcode.
array $node_array: Node_array.
Return value
bool True or false.
1 call to MergeTranslationsForm::addTranslation()
- MergeTranslationsForm::mergeTranslations in src/
Form/ MergeTranslationsForm.php - MergeTranslations.
File
- src/
Form/ MergeTranslationsForm.php, line 351
Class
- MergeTranslationsForm
- The merge translation form.
Namespace
Drupal\merge_translations\FormCode
private function addTranslation($langcode, array $node_array) {
$this->moduleHandler
->invokeAll('merge_translations_prepare_alter', [
&$node_array,
]);
$node_target = $this->node;
$message_argumens = [
'@langcode' => $langcode,
'@title' => $node_target
->getTitle(),
];
if (!$node_target
->hasTranslation($langcode)) {
$node_target
->addTranslation($langcode, $node_array);
$this->messenger
->addStatus($this
->t('Add @langcode translation to node @title.', $message_argumens));
return TRUE;
}
$this->messenger
->addWarning($this
->t('Translation @langcode already exist in node @title.', $message_argumens));
return FALSE;
}