diff -u b/core/modules/system/lib/Drupal/system/Controller/ThemeListingController.php b/core/modules/system/lib/Drupal/system/Controller/ThemeListingController.php --- b/core/modules/system/lib/Drupal/system/Controller/ThemeListingController.php +++ b/core/modules/system/lib/Drupal/system/Controller/ThemeListingController.php @@ -10,6 +10,7 @@ use Drupal\Core\Controller\ControllerInterface; use Drupal\Core\Config\Config; use Drupal\Core\Extension\ModuleHandler; +use Drupal\Core\StringTranslation\TranslationManager; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; @@ -26,18 +27,33 @@ protected $config; /** - * The module handler object. + * The module handler service. * * @var \Drupal\Core\Extension\ModuleHandler */ protected $moduleHandler; /** + * The translation manager service. + * + * @var \Drupal\Core\StringTranslation\TranslationManager + */ + protected $translation; + + /** * Constructs a ThemeListingController object. + * + * @param \Drupal\Core\Config\Config $config + * The system.theme config object. + * @param \Drupal\Core\Extension\ModuleHandler $module_handler + * The module handler service. + * @param \Drupal\Core\StringTranslation\TranslationManager $translation + * The translation manager service. */ - public function __construct(Config $config, ModuleHandler $module_handler) { + public function __construct(Config $config, ModuleHandler $module_handler, TranslationManager $translation) { $this->config = $config; $this->moduleHandler = $module_handler; + $this->translation = $translation; } /** @@ -46,10 +62,17 @@ public static function create(ContainerInterface $container) { return new static( $container->get('config.factory')->get('system.theme'), - $container->get('module_handler') + $container->get('module_handler'), + $container->get('string_translation') ); } + /** + * Returns a theme listing. + * + * @return string + * A HTML string of the theme listing page. + */ public function listingPage() { // Get current list of themes. $themes = system_rebuild_theme_data(); @@ -80,8 +103,8 @@ if (isset($themes[$theme_key]) && file_exists($themes[$theme_key]->info['screenshot'])) { $theme->screenshot = array( 'uri' => $themes[$theme_key]->info['screenshot'], - 'alt' => t('Screenshot for !theme theme', array('!theme' => $theme->info['name'])), - 'title' => t('Screenshot for !theme theme', array('!theme' => $theme->info['name'])), + 'alt' => $this->translation->translate('Screenshot for !theme theme', array('!theme' => $theme->info['name'])), + 'title' => $this->translation->translate('Screenshot for !theme theme', array('!theme' => $theme->info['name'])), 'attributes' => array('class' => array('screenshot')), ); break; @@ -106,42 +129,42 @@ $query['theme'] = $theme->name; if (drupal_theme_access($theme)) { $theme->operations[] = array( - 'title' => t('Settings'), + 'title' => $this->translation->translate('Settings'), 'href' => 'admin/appearance/settings/' . $theme->name, - 'attributes' => array('title' => t('Settings for !theme theme', array('!theme' => $theme->info['name']))), + 'attributes' => array('title' => $this->translation->translate('Settings for !theme theme', array('!theme' => $theme->info['name']))), ); } if (!empty($theme->status)) { if (!$theme->is_default) { if ($theme->name != $admin_theme) { $theme->operations[] = array( - 'title' => t('Disable'), + 'title' => $this->translation->translate('Disable'), 'href' => 'admin/appearance/disable', 'query' => $query, - 'attributes' => array('title' => t('Disable !theme theme', array('!theme' => $theme->info['name']))), + 'attributes' => array('title' => $this->translation->translate('Disable !theme theme', array('!theme' => $theme->info['name']))), ); } $theme->operations[] = array( - 'title' => t('Set default'), + 'title' => $this->translation->translate('Set default'), 'href' => 'admin/appearance/default', 'query' => $query, - 'attributes' => array('title' => t('Set !theme as default theme', array('!theme' => $theme->info['name']))), + 'attributes' => array('title' => $this->translation->translate('Set !theme as default theme', array('!theme' => $theme->info['name']))), ); } $admin_theme_options[$theme->name] = $theme->info['name']; } else { $theme->operations[] = array( - 'title' => t('Enable'), + 'title' => $this->translation->translate('Enable'), 'href' => 'admin/appearance/enable', 'query' => $query, - 'attributes' => array('title' => t('Enable !theme theme', array('!theme' => $theme->info['name']))), + 'attributes' => array('title' => $this->translation->translate('Enable !theme theme', array('!theme' => $theme->info['name']))), ); $theme->operations[] = array( - 'title' => t('Enable and set default'), + 'title' => $this->translation->translate('Enable and set default'), 'href' => 'admin/appearance/default', 'query' => $query, - 'attributes' => array('title' => t('Enable !theme as default theme', array('!theme' => $theme->info['name']))), + 'attributes' => array('title' => $this->translation->translate('Enable !theme as default theme', array('!theme' => $theme->info['name']))), ); } } @@ -151,11 +174,11 @@ $theme->classes = array(); if ($theme->is_default) { $theme->classes[] = 'theme-default'; - $theme->notes[] = t('default theme'); + $theme->notes[] = $this->translation->translate('default theme'); } if ($theme->name == $admin_theme || ($theme->is_default && $admin_theme == '0')) { $theme->classes[] = 'theme-admin'; - $theme->notes[] = t('admin theme'); + $theme->notes[] = $this->translation->translate('admin theme'); } // Sort enabled and disabled themes into their own groups. diff -u b/core/modules/system/system.module b/core/modules/system/system.module --- b/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -667,6 +667,7 @@ $items['admin/appearance'] = array( 'title' => 'Appearance', 'description' => 'Select and configure your themes.', + 'route_name' => 'system_theme_listing', 'position' => 'left', 'weight' => -6, );