The idiom that the community points to for creating menu links usually looks like this (from \Drupal\Tests\language\Functional\LanguageSwitchingTest::testLanguageSessionSwitchLinks()
):
// Add a link to the homepage.
$link = MenuLinkContent::create([
'title' => 'Home',
'menu_name' => 'main',
'bundle' => 'menu_link_content',
'link' => [['uri' => 'entity:user/2']],
]);
$link->save();
Note that the title
is not run through t()
.
But, yet, the idiom for shortcut links (from standard_install()
) is:
// Populate the default shortcut set.
$shortcut = Shortcut::create([
'shortcut_set' => 'default',
'title' => t('Add content'),
'weight' => -20,
'link' => ['uri' => 'internal:/node/add'],
]);
$shortcut->save();
Note that the title
is run through t()
.
Why are shortcut titles run through translation at creation time, but menu link titles are not? Aren't shortcuts a type of menu link? Shouldn't they be handled the same way?
t
t
on the title instandard_install
is pointless at best