diff --git a/core/modules/shortcut/shortcut.module b/core/modules/shortcut/shortcut.module index 6f446c1..efd4752 100644 --- a/core/modules/shortcut/shortcut.module +++ b/core/modules/shortcut/shortcut.module @@ -302,6 +302,7 @@ function shortcut_renderable_links($shortcut_set = NULL) { $shortcuts = \Drupal::entityManager()->getStorage('shortcut')->loadByProperties(array('shortcut_set' => $shortcut_set->id())); $all_cache_tags = array(); foreach ($shortcuts as $shortcut) { + $shortcut = \Drupal::entityManager()->getTranslationFromContext($shortcut); $links[] = array( 'title' => $shortcut->label(), 'href' => $shortcut->path->value, diff --git a/core/modules/shortcut/src/Tests/ShortcutTranslationUITest.php b/core/modules/shortcut/src/Tests/ShortcutTranslationUITest.php index 78c50d1..827fd10 100644 --- a/core/modules/shortcut/src/Tests/ShortcutTranslationUITest.php +++ b/core/modules/shortcut/src/Tests/ShortcutTranslationUITest.php @@ -8,6 +8,7 @@ namespace Drupal\shortcut\Tests; use Drupal\content_translation\Tests\ContentTranslationUITest; +use Drupal\Core\Language\Language; /** * Tests the shortcut translation UI. @@ -25,6 +26,7 @@ class ShortcutTranslationUITest extends ContentTranslationUITest { 'language', 'content_translation', 'shortcut', + 'toolbar' ); /** @@ -41,7 +43,7 @@ protected function setUp() { * {@inheritdoc} */ protected function getTranslatorPermissions() { - return array_merge(parent::getTranslatorPermissions(), array('administer shortcuts')); + return array_merge(parent::getTranslatorPermissions(), array('access shortcuts', 'administer shortcuts', 'access toolbar')); } /** @@ -52,4 +54,20 @@ protected function createEntity($values, $langcode, $bundle_name = NULL) { return parent::createEntity($values, $langcode, $bundle_name); } + protected function doTestBasicTranslation() { + parent::doTestBasicTranslation(); + + $entity = entity_load($this->entityTypeId, $this->entityId, TRUE); + foreach ($this->langcodes as $langcode) { + if ($entity->hasTranslation($langcode)) { + $language = new Language(array('id' => $langcode)); + $path = \Drupal::urlGenerator()->generateFromRoute('', array(), array('language' => $language)); + $this->drupalGet($path); + $expected_path = \Drupal::urlGenerator()->generateFromRoute('system.admin', array(), array('language' => $language)); + $elements = $this->xpath('//nav[contains(@class, "toolbar-lining")]/ul[@class="menu"]/li/a[@href=:href]', array(':href' => $expected_path)); + $this->assertEqual((string) $elements[0], $entity->getTranslation($langcode)->label()); + } + } + } + }