If you change the micro site's language while creating it, the menu that will be created will be in a different language than the micro site's current language.
When creating the micro site menu, set langcode
to micro site's language.
/**
* Implements hook_ENTITY_TYPE_insert().
*/
function micro_menu_site_insert(EntityInterface $entity) {
...
$site_menu = $entity->getSiteMenu();
if (empty($site_menu)) {
/** @var \Drupal\system\Entity\Menu $menu */
$menu = Menu::create([
'id' => 'site-' . $entity->id(),
'label' => 'Menu ' . $entity->label(),
'description' => t('The menu for the site @label (id: @id)', ['@label' => $entity->label(), '@id' => $entity->id()]),
'locked' => TRUE,
'third_party_settings' => ['micro_menu' => ['site_id' => $entity->id()]],
'langcode' => $entity->language()->getId(),
])->save();
...
}
}
None.
None.
None.
None.
Needs review
1.0
Code