diff --git a/core/modules/content_translation/content_translation.admin.inc b/core/modules/content_translation/content_translation.admin.inc index a7bfc1d244dd6674a58fea3d4d4b3e7a724a54da..2fd1e27e7c444c1852a4a144a6571a5ce4443911 100644 --- a/core/modules/content_translation/content_translation.admin.inc +++ b/core/modules/content_translation/content_translation.admin.inc @@ -255,6 +255,7 @@ function _content_translation_preprocess_language_content_settings_table(&$varia 'class' => ['operations'], ], ], + '#field_name' => $field_name, 'class' => ['field-settings'], ]; diff --git a/core/modules/layout_builder/css/layout-builder-content-translation.css b/core/modules/layout_builder/css/layout-builder-content-translation.css new file mode 100644 index 0000000000000000000000000000000000000000..bff9c47067d9259f7439b83958339a1cc6077748 --- /dev/null +++ b/core/modules/layout_builder/css/layout-builder-content-translation.css @@ -0,0 +1,5 @@ +/* @todo Move this to Seven as part of https://www.drupal.org/node/3041053 */ +.layout-builder-translation-warning { + background: left 2px url(../../../misc/icons/e29700/warning.svg) no-repeat; + padding-left: 20px; +} diff --git a/core/modules/layout_builder/layout_builder.libraries.yml b/core/modules/layout_builder/layout_builder.libraries.yml index d77b6213685a466015d67962563b4a490c527f7c..57b65605ca1111e8af45a55bdaeaa6639a701cc9 100644 --- a/core/modules/layout_builder/layout_builder.libraries.yml +++ b/core/modules/layout_builder/layout_builder.libraries.yml @@ -27,3 +27,9 @@ fourcol_section: css: theme: layouts/fourcol_section/fourcol_section.css: {} + +drupal.layout_builder_content_translation_admin: + version: VERSION + css: + theme: + css/layout-builder-content-translation.css: {} diff --git a/core/modules/layout_builder/layout_builder.module b/core/modules/layout_builder/layout_builder.module index d369096505e8be8d9898c24c9e35614ff8740a73..b20ddfb126da2f56ce5e7b04a74407c16b24e144 100644 --- a/core/modules/layout_builder/layout_builder.module +++ b/core/modules/layout_builder/layout_builder.module @@ -367,3 +367,46 @@ function layout_builder_entity_translation_create(EntityInterface $translation) $translation->set(OverridesSectionStorage::FIELD_NAME, []); } } + +/** + * Implements hook_theme_registry_alter(). + */ +function layout_builder_theme_registry_alter(&$theme_registry) { + // Move our preprocess to run after + // content_translation_preprocess_language_content_settings_table(). + if (!empty($theme_registry['language_content_settings_table']['preprocess functions'])) { + $preprocess_functions = &$theme_registry['language_content_settings_table']['preprocess functions']; + $index = array_search('layout_builder_preprocess_language_content_settings_table', $preprocess_functions); + if ($index !== FALSE) { + unset($preprocess_functions[$index]); + $preprocess_functions[] = 'layout_builder_preprocess_language_content_settings_table'; + } + } +} + +/** + * Implements hook_preprocess_HOOK() for language-content-settings-table.html.twig. + */ +function layout_builder_preprocess_language_content_settings_table(&$variables) { + foreach ($variables['build']['#rows'] as &$row) { + if (isset($row['#field_name']) && $row['#field_name'] === OverridesSectionStorage::FIELD_NAME) { + // Rebuild the label to include a warning about using translations with + // layouts. + $row['data'][1]['data']['field'] = [ + 'label' => $row['data'][1]['data']['field'], + 'description' => [ + '#type' => 'container', + '#markup' => t('<strong>Warning</strong>: Layout Builder does not support translating layouts. (<a href="https://www.drupal.org/docs/8/core/modules/layout-builder/layout-builder-and-content-translation">online documentation</a>)'), + '#attributes' => [ + 'class' => ['layout-builder-translation-warning'], + ], + '#attached' => [ + 'library' => [ + 'layout_builder/drupal.layout_builder_content_translation_admin', + ], + ], + ], + ]; + } + } +}