diff --git a/core/modules/views_ui/js/views-admin.js b/core/modules/views_ui/js/views-admin.js index 3cc0f4c..6a74d69 100644 --- a/core/modules/views_ui/js/views-admin.js +++ b/core/modules/views_ui/js/views-admin.js @@ -349,14 +349,11 @@ var $displayButtons = $menu.nextAll('input.add-display').detach(); $displayButtons.appendTo($addDisplayDropdown.find('.action-list')).wrap('
  • ') .parent().eq(0).addClass('first').end().eq(-1).addClass('last'); - // Remove the 'Add ' prefix from the button labels since they're being - // placed in an 'Add' dropdown. @todo This assumes English, but so does - // $addDisplayDropdown above. Add support for translation. + + // Place buttons in an 'Add' dropdown. $displayButtons.each(function () { - var label = $(this).val(); - if (label.substr(0, 4) === 'Add ') { - $(this).val(label.substr(4)); - } + var $this = $(this); + $this.val($this.attr('data-drupal-dropdown-label')); }); $addDisplayDropdown.appendTo($menu); diff --git a/core/modules/views_ui/src/ViewEditForm.php b/core/modules/views_ui/src/ViewEditForm.php index 5f8c095..22e8087 100644 --- a/core/modules/views_ui/src/ViewEditForm.php +++ b/core/modules/views_ui/src/ViewEditForm.php @@ -747,7 +747,10 @@ public function renderDisplayTop(ViewUI $view) { '#value' => $this->t('Add @display', array('@display' => $label)), '#limit_validation_errors' => array(), '#submit' => array('::submitDisplayAdd', '::submitDelayDestination'), - '#attributes' => array('class' => array('add-display')), + '#attributes' => array( + 'class' => array('add-display'), + 'data-drupal-dropdown-label' => $this->t('@display', array('@display' => $label)), + ), // Allow JavaScript to remove the 'Add ' prefix from the button label when // placing the button in a "Add" dropdown menu. '#process' => array_merge(array('views_ui_form_button_was_clicked'), $this->elementInfo->getInfoProperty('submit', '#process', array())),