Skip to content

Commit 032a019

Browse files
authored
Remove usages of dt() (#6500)
* Remove usages of dt() * more
1 parent d8ee8d4 commit 032a019

7 files changed

Lines changed: 17 additions & 21 deletions

File tree

src/Commands/cache/CacheRebuildCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected function configure(): void
5151
public function execute(InputInterface $input, OutputInterface $output): int
5252
{
5353
if (str_contains(strval($input), 'cache-clear') && !$input->getoption('cache-clear')) {
54-
$this->logger->info(dt("Skipping cache:rebuild due to --no-cache-clear option."));
54+
$this->logger->info("Skipping cache:rebuild due to --no-cache-clear option.");
5555
return self::SUCCESS;
5656
}
5757

src/Commands/cache/CacheWarmCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static function create(ContainerInterface $container)
4747
protected function execute(InputInterface $input, OutputInterface $output): int
4848
{
4949
$this->warmer->preWarmAllCaches();
50-
(new DrushStyle($input, $output))->success(dt('Warmed caches.'));
50+
(new DrushStyle($input, $output))->success('Warmed caches.');
5151
return self::SUCCESS;
5252
}
5353
}

src/Commands/deploy/DeployHookCommand.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,7 @@ public static function updateDoOneDeployHook(string $function, array $context):
158158
}
159159
} else {
160160
$ret['#abort'] = ['success' => false];
161-
Drush::logger()->warning(dt('Deploy hook function @function not found in file @filename', [
162-
'@function' => $function,
163-
'@filename' => "$filename.php",
164-
]));
161+
Drush::logger()->warning(sprintf('Deploy hook function %s not found in file %s', $function, "$filename.php"));
165162
}
166163

167164
if (isset($context['sandbox']['#finished'])) {

src/Commands/generate/GenerateCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
7070
$all = $application->all();
7171
unset($all['help'], $all['list'], $all['completion']);
7272
$namespaced = ListCommand::categorize($all);
73-
$preamble = dt('Run `drush generate [command]` and answer a few questions in order to write starter code to your project.');
73+
$preamble = 'Run `drush generate [command]` and answer a few questions in order to write starter code to your project.';
7474
ListCommand::renderListCLI($application, $namespaced, $output, $preamble);
7575
return self::SUCCESS;
7676
}

src/Commands/pm/PmTrait.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Drush\Commands\pm;
66

7+
use Drupal;
78
use Drupal\Core\Config\ConfigFactoryInterface;
89
use Drupal\Core\Extension\Extension;
910
use Drupal\Core\Extension\MissingDependencyException;
@@ -13,7 +14,6 @@
1314
use Drupal\Core\Link;
1415
use Drupal\Core\Url;
1516
use Drupal\user\PermissionHandlerInterface;
16-
use Drupal;
1717

1818
trait PmTrait
1919
{
@@ -78,7 +78,7 @@ public function addUninstallDependencies($modules): false|array
7878
$module_data = $this->extensionListModule->reset()->getList();
7979
$module_list = array_combine($modules, $modules);
8080
if ($diff = array_diff_key($module_list, $module_data)) {
81-
throw new \Exception(dt('A specified extension does not exist: !diff', ['!diff' => implode(',', $diff)]));
81+
throw new \Exception(sprintf('A specified extension does not exist: %s', implode(',', $diff)));
8282
}
8383
$extension_config = $this->configFactory->getEditable('core.extension');
8484
$installed_modules = $extension_config->get('module') ?: [];
@@ -124,19 +124,19 @@ protected function getModuleLinks(Extension $module): array
124124
// implementation exists then the module provides an overview page, rather
125125
// than checking to see if the page exists, which is costly.
126126
if ($this->moduleHandler->moduleExists('help') && $module->status && $this->moduleHandler->hasImplementations('help', $module->getName())) {
127-
$links[] = Link::fromTextAndUrl(dt('Help'), Url::fromRoute('help.page', ['name' => $module->getName()]));
127+
$links[] = Link::fromTextAndUrl('Help', Url::fromRoute('help.page', ['name' => $module->getName()]));
128128
}
129129

130130
// Generate link for module's permissions page.
131131
// Avoid DI for PermissionHandler until we understand better at https://github.com/drush-ops/drush/issues/6154.
132132
if ($module->status && Drupal::service(PermissionHandlerInterface::class)->moduleProvidesPermissions($module->getName())) {
133-
$links[] = Link::fromTextAndUrl(dt('Permissions'), Url::fromRoute('user.admin_permissions.module', ['modules' => $module->getName()]));
133+
$links[] = Link::fromTextAndUrl('Permissions', Url::fromRoute('user.admin_permissions.module', ['modules' => $module->getName()]));
134134
}
135135

136136
// Generate link for module's configuration page, if it has one.
137137
if ($module->status && isset($module->info['configure'])) {
138138
$route_parameters = $module->info['configure_parameters'] ?? [];
139-
$links[] = Link::fromTextAndUrl(dt('Configure'), Url::fromRoute($module->info['configure'], $route_parameters));
139+
$links[] = Link::fromTextAndUrl('Configure', Url::fromRoute($module->info['configure'], $route_parameters));
140140
}
141141

142142
return $links;

src/Commands/pm/ThemeInstallCommand.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
5353
$themes = StringUtils::csvToArray($themes);
5454

5555
$todo = $this->addInstallDependencies($themes, 'themes');
56-
$todo_str = ['!list' => implode(', ', $todo)];
57-
if ($todo !== []) {
58-
$output->writeln(dt('The following module(s) and themes(s) will be installed: !list', $todo_str));
59-
if (!$io->confirm(dt('Do you want to continue?'))) {
56+
if ($todo) {
57+
$output->writeln(sprintf('The following module(s) and themes(s) will be installed: %s', implode(', ', $todo)));
58+
if (!$io->confirm('Do you want to continue?')) {
6059
throw new UserAbortException();
6160
}
6261

src/Commands/user/UserLoginCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,28 +69,28 @@ public function execute(InputInterface $input, OutputInterface $output): int
6969
$link = $process->getOutput();
7070
} else {
7171
if (!$this->bootstrapManager->doBootstrap(DrupalBootLevels::FULL)) {
72-
throw new \Exception(dt('Unable to bootstrap Drupal.'));
72+
throw new \Exception('Unable to bootstrap Drupal.');
7373
}
7474

7575
$account = null;
7676
if ($input->getOption('name') && !$account = user_load_by_name($input->getOption('name'))) {
77-
throw new \Exception(dt('Unable to load user by name: !name', ['!name' => $input->getOption('name')]));
77+
throw new \Exception(sprintf('Unable to load user by name: %s', $input->getOption('name')));
7878
}
7979

8080
if ($input->getOption('uid') && !$account = User::load($input->getOption('uid'))) {
81-
throw new \Exception(dt('Unable to load user by uid: !uid', ['!uid' => $input->getOption('uid')]));
81+
throw new \Exception(sprintf('Unable to load user by uid: %s', $input->getOption('uid')));
8282
}
8383

8484
if ($input->getOption('mail') && !$account = user_load_by_mail($input->getOption('mail'))) {
85-
throw new \Exception(dt('Unable to load user by mail: !mail', ['!mail' => $input->getOption('mail')]));
85+
throw new \Exception(sprintf('Unable to load user by mail: %s', $input->getOption('mail')));
8686
}
8787

8888
if (empty($account)) {
8989
$account = User::load(1);
9090
}
9191

9292
if ($account->isBlocked()) {
93-
throw new \InvalidArgumentException(dt('Account !name is blocked and thus cannot login. The user:unblock command may be helpful.', ['!name' => $account->getAccountName()]));
93+
throw new \InvalidArgumentException('Account %s is blocked and thus cannot login. The user:unblock command may be helpful.', $account->getAccountName());
9494
}
9595

9696
// Can't inject dependency because this command instantiates without a bootstrap.

0 commit comments

Comments
 (0)