Skip to content

Commit 100d4ee

Browse files
committed
Remove more unnecessary translations
1 parent 0e3e14a commit 100d4ee

File tree

3 files changed

+58
-126
lines changed

3 files changed

+58
-126
lines changed
Lines changed: 39 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,31 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Console\Commands\Environment;
114

125
use DateTimeZone;
136
use Illuminate\Console\Command;
147
use Illuminate\Contracts\Console\Kernel;
15-
use Illuminate\Validation\Factory as ValidatorFactory;
168
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
17-
use Illuminate\Contracts\Config\Repository as ConfigRepository;
189

1910
class AppSettingsCommand extends Command
2011
{
2112
use EnvironmentWriterTrait;
2213

23-
public const ALLOWED_CACHE_DRIVERS = [
14+
public const CACHE_DRIVERS = [
2415
'redis' => 'Redis (recommended)',
2516
'memcached' => 'Memcached',
2617
'file' => 'Filesystem',
2718
];
2819

29-
public const ALLOWED_SESSION_DRIVERS = [
20+
public const SESSION_DRIVERS = [
3021
'redis' => 'Redis (recommended)',
3122
'memcached' => 'Memcached',
3223
'database' => 'MySQL Database',
3324
'file' => 'Filesystem',
3425
'cookie' => 'Cookie',
3526
];
3627

37-
public const ALLOWED_QUEUE_DRIVERS = [
28+
public const QUEUE_DRIVERS = [
3829
'redis' => 'Redis (recommended)',
3930
'database' => 'MySQL Database',
4031
'sync' => 'Sync',
@@ -45,11 +36,6 @@ class AppSettingsCommand extends Command
4536
*/
4637
protected $command;
4738

48-
/**
49-
* @var \Illuminate\Contracts\Config\Repository
50-
*/
51-
protected $config;
52-
5339
/**
5440
* @var string
5541
*/
@@ -79,13 +65,11 @@ class AppSettingsCommand extends Command
7965
/**
8066
* AppSettingsCommand constructor.
8167
*/
82-
public function __construct(ConfigRepository $config, Kernel $command, ValidatorFactory $validator)
68+
public function __construct(Kernel $command)
8369
{
8470
parent::__construct();
8571

86-
$this->config = $config;
8772
$this->command = $command;
88-
$this->validator = $validator;
8973
}
9074

9175
/**
@@ -95,67 +79,60 @@ public function __construct(ConfigRepository $config, Kernel $command, Validator
9579
*/
9680
public function handle()
9781
{
98-
if (empty($this->config->get('hashids.salt')) || $this->option('new-salt')) {
82+
if (empty(config('hashids.salt')) || $this->option('new-salt')) {
9983
$this->variables['HASHIDS_SALT'] = str_random(20);
10084
}
10185

102-
$this->output->comment(trans('command/messages.environment.app.author_help'));
86+
$this->output->comment('Provide the email address that eggs exported by this Panel should be from. This should be a valid email address.');
10387
$this->variables['APP_SERVICE_AUTHOR'] = $this->option('author') ?? $this->ask(
104-
trans('command/messages.environment.app.author'),
105-
$this->config->get('pterodactyl.service.author', 'unknown@unknown.com')
106-
);
107-
108-
$validator = $this->validator->make(
109-
['email' => $this->variables['APP_SERVICE_AUTHOR']],
110-
['email' => 'email']
88+
'Egg Author Email',
89+
config('pterodactyl.service.author', 'unknown@unknown.com')
11190
);
11291

113-
if ($validator->fails()) {
114-
foreach ($validator->errors()->all() as $error) {
115-
$this->output->error($error);
116-
}
92+
if (!filter_var($this->variables['APP_SERVICE_AUTHOR'], FILTER_VALIDATE_EMAIL)) {
93+
$this->output->error('The service author email provided is invalid.');
11794

11895
return 1;
11996
}
12097

121-
$this->output->comment(trans('command/messages.environment.app.app_url_help'));
98+
$this->output->comment('The application URL MUST begin with https:// or http:// depending on if you are using SSL or not. If you do not include the scheme your emails and other content will link to the wrong location.');
12299
$this->variables['APP_URL'] = $this->option('url') ?? $this->ask(
123-
trans('command/messages.environment.app.app_url'),
124-
$this->config->get('app.url', 'http://example.org')
100+
'Application URL',
101+
config('app.url', 'http://example.org')
125102
);
126103

127-
$this->output->comment(trans('command/messages.environment.app.timezone_help'));
104+
$this->output->comment('The timezone should match one of PHP\'s supported timezones. If you are unsure, please reference http://php.net/manual/en/timezones.php.');
128105
$this->variables['APP_TIMEZONE'] = $this->option('timezone') ?? $this->anticipate(
129-
trans('command/messages.environment.app.timezone'),
106+
'Application Timezone',
130107
DateTimeZone::listIdentifiers(DateTimeZone::ALL),
131-
$this->config->get('app.timezone')
108+
config('app.timezone')
132109
);
133110

134-
$selected = $this->config->get('cache.default', 'redis');
111+
$selected = config('cache.default', 'redis');
135112
$this->variables['CACHE_DRIVER'] = $this->option('cache') ?? $this->choice(
136-
trans('command/messages.environment.app.cache_driver'),
137-
self::ALLOWED_CACHE_DRIVERS,
138-
array_key_exists($selected, self::ALLOWED_CACHE_DRIVERS) ? $selected : null
113+
'Cache Driver',
114+
self::CACHE_DRIVERS,
115+
array_key_exists($selected, self::CACHE_DRIVERS) ? $selected : null
139116
);
140117

141-
$selected = $this->config->get('session.driver', 'redis');
118+
$selected = config('session.driver', 'redis');
142119
$this->variables['SESSION_DRIVER'] = $this->option('session') ?? $this->choice(
143-
trans('command/messages.environment.app.session_driver'),
144-
self::ALLOWED_SESSION_DRIVERS,
145-
array_key_exists($selected, self::ALLOWED_SESSION_DRIVERS) ? $selected : null
120+
'Session Driver',
121+
self::SESSION_DRIVERS,
122+
array_key_exists($selected, self::SESSION_DRIVERS) ? $selected : null
146123
);
147124

148-
$selected = $this->config->get('queue.default', 'redis');
125+
$selected = config('queue.default', 'redis');
149126
$this->variables['QUEUE_CONNECTION'] = $this->option('queue') ?? $this->choice(
150-
trans('command/messages.environment.app.queue_driver'),
151-
self::ALLOWED_QUEUE_DRIVERS,
152-
array_key_exists($selected, self::ALLOWED_QUEUE_DRIVERS) ? $selected : null
127+
'Queue Driver',
128+
self::QUEUE_DRIVERS,
129+
array_key_exists($selected, self::QUEUE_DRIVERS) ? $selected : null
153130
);
154131

155132
if (!is_null($this->option('settings-ui'))) {
156133
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->option('settings-ui') == 'true' ? 'false' : 'true';
157134
} else {
158-
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->confirm(trans('command/messages.environment.app.settings'), true) ? 'false' : 'true';
135+
$this->variables['APP_ENVIRONMENT_ONLY'] = $this->confirm('Enable UI based settings editor?', true) ? 'false' : 'true';
159136
}
160137

161138
// Make sure session cookies are set as "secure" when using HTTPS
@@ -183,22 +160,22 @@ private function checkForRedis()
183160
return;
184161
}
185162

186-
$this->output->note(trans('command/messages.environment.app.using_redis'));
163+
$this->output->note('You\'ve selected the Redis driver for one or more options, please provide valid connection information below. In most cases you can use the defaults provided unless you have modified your setup.');
187164
$this->variables['REDIS_HOST'] = $this->option('redis-host') ?? $this->ask(
188-
trans('command/messages.environment.app.redis_host'),
189-
$this->config->get('database.redis.default.host')
165+
'Redis Host',
166+
config('database.redis.default.host')
190167
);
191168

192169
$askForRedisPassword = true;
193-
if (!empty($this->config->get('database.redis.default.password'))) {
194-
$this->variables['REDIS_PASSWORD'] = $this->config->get('database.redis.default.password');
195-
$askForRedisPassword = $this->confirm(trans('command/messages.environment.app.redis_pass_defined'));
170+
if (!empty(config('database.redis.default.password'))) {
171+
$this->variables['REDIS_PASSWORD'] = config('database.redis.default.password');
172+
$askForRedisPassword = $this->confirm('It seems a password is already defined for Redis, would you like to change it?');
196173
}
197174

198175
if ($askForRedisPassword) {
199-
$this->output->comment(trans('command/messages.environment.app.redis_pass_help'));
176+
$this->output->comment('By default a Redis server instance has no password as it is running locally and inaccessible to the outside world. If this is the case, simply hit enter without entering a value.');
200177
$this->variables['REDIS_PASSWORD'] = $this->option('redis-pass') ?? $this->output->askHidden(
201-
trans('command/messages.environment.app.redis_password')
178+
'Redis Password'
202179
);
203180
}
204181

@@ -207,8 +184,8 @@ private function checkForRedis()
207184
}
208185

209186
$this->variables['REDIS_PORT'] = $this->option('redis-port') ?? $this->ask(
210-
trans('command/messages.environment.app.redis_port'),
211-
$this->config->get('database.redis.default.port')
187+
'Redis Port',
188+
config('database.redis.default.port')
212189
);
213190
}
214191
}

app/Console/Commands/Environment/DatabaseSettingsCommand.php

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
<?php
2-
/**
3-
* Pterodactyl - Panel
4-
* Copyright (c) 2015 - 2017 Dane Everitt <dane@daneeveritt.com>.
5-
*
6-
* This software is licensed under the terms of the MIT license.
7-
* https://opensource.org/licenses/MIT
8-
*/
92

103
namespace Pterodactyl\Console\Commands\Environment;
114

@@ -14,17 +7,11 @@
147
use Illuminate\Contracts\Console\Kernel;
158
use Illuminate\Database\DatabaseManager;
169
use Pterodactyl\Traits\Commands\EnvironmentWriterTrait;
17-
use Illuminate\Contracts\Config\Repository as ConfigRepository;
1810

1911
class DatabaseSettingsCommand extends Command
2012
{
2113
use EnvironmentWriterTrait;
2214

23-
/**
24-
* @var \Illuminate\Contracts\Config\Repository
25-
*/
26-
protected $config;
27-
2815
/**
2916
* @var \Illuminate\Contracts\Console\Kernel
3017
*/
@@ -58,11 +45,10 @@ class DatabaseSettingsCommand extends Command
5845
/**
5946
* DatabaseSettingsCommand constructor.
6047
*/
61-
public function __construct(ConfigRepository $config, DatabaseManager $database, Kernel $console)
48+
public function __construct(DatabaseManager $database, Kernel $console)
6249
{
6350
parent::__construct();
6451

65-
$this->config = $config;
6652
$this->console = $console;
6753
$this->database = $database;
6854
}
@@ -76,45 +62,45 @@ public function __construct(ConfigRepository $config, DatabaseManager $database,
7662
*/
7763
public function handle()
7864
{
79-
$this->output->note(trans('command/messages.environment.database.host_warning'));
65+
$this->output->note('It is highly recommended to not use "localhost" as your database host as we have seen frequent socket connection issues. If you want to use a local connection you should be using "127.0.0.1".');
8066
$this->variables['DB_HOST'] = $this->option('host') ?? $this->ask(
81-
trans('command/messages.environment.database.host'),
82-
$this->config->get('database.connections.mysql.host', '127.0.0.1')
67+
'Database Host',
68+
config('database.connections.mysql.host', '127.0.0.1')
8369
);
8470

8571
$this->variables['DB_PORT'] = $this->option('port') ?? $this->ask(
86-
trans('command/messages.environment.database.port'),
87-
$this->config->get('database.connections.mysql.port', 3306)
72+
'Database Port',
73+
config('database.connections.mysql.port', 3306)
8874
);
8975

9076
$this->variables['DB_DATABASE'] = $this->option('database') ?? $this->ask(
91-
trans('command/messages.environment.database.database'),
92-
$this->config->get('database.connections.mysql.database', 'panel')
77+
'Database Name',
78+
config('database.connections.mysql.database', 'panel')
9379
);
9480

95-
$this->output->note(trans('command/messages.environment.database.username_warning'));
81+
$this->output->note('Using the "root" account for MySQL connections is not only highly frowned upon, it is also not allowed by this application. You\'ll need to have created a MySQL user for this software.');
9682
$this->variables['DB_USERNAME'] = $this->option('username') ?? $this->ask(
97-
trans('command/messages.environment.database.username'),
98-
$this->config->get('database.connections.mysql.username', 'pterodactyl')
83+
'Database Username',
84+
config('database.connections.mysql.username', 'pterodactyl')
9985
);
10086

10187
$askForMySQLPassword = true;
102-
if (!empty($this->config->get('database.connections.mysql.password')) && $this->input->isInteractive()) {
103-
$this->variables['DB_PASSWORD'] = $this->config->get('database.connections.mysql.password');
104-
$askForMySQLPassword = $this->confirm(trans('command/messages.environment.database.password_defined'));
88+
if (!empty(config('database.connections.mysql.password')) && $this->input->isInteractive()) {
89+
$this->variables['DB_PASSWORD'] = config('database.connections.mysql.password');
90+
$askForMySQLPassword = $this->confirm('It appears you already have a MySQL connection password defined, would you like to change it?');
10591
}
10692

10793
if ($askForMySQLPassword) {
108-
$this->variables['DB_PASSWORD'] = $this->option('password') ?? $this->secret(trans('command/messages.environment.database.password'));
94+
$this->variables['DB_PASSWORD'] = $this->option('password') ?? $this->secret('Database Password');
10995
}
11096

11197
try {
11298
$this->testMySQLConnection();
11399
} catch (PDOException $exception) {
114-
$this->output->error(trans('command/messages.environment.database.connection_error', ['error' => $exception->getMessage()]));
115-
$this->output->error(trans('command/messages.environment.database.creds_not_saved'));
100+
$this->output->error(sprintf('Unable to connect to the MySQL server using the provided credentials. The error returned was "%s".', $exception->getMessage()));
101+
$this->output->error('Your connection credentials have NOT been saved. You will need to provide valid connection information before proceeding.');
116102

117-
if ($this->confirm(trans('command/messages.environment.database.try_again'))) {
103+
if ($this->confirm('Go back and try again?')) {
118104
$this->database->disconnect('_pterodactyl_command_test');
119105

120106
return $this->handle();
@@ -135,7 +121,7 @@ public function handle()
135121
*/
136122
private function testMySQLConnection()
137123
{
138-
$this->config->set('database.connections._pterodactyl_command_test', [
124+
config()->set('database.connections._pterodactyl_command_test', [
139125
'driver' => 'mysql',
140126
'host' => $this->variables['DB_HOST'],
141127
'port' => $this->variables['DB_PORT'],

resources/lang/en/command/messages.php

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -62,36 +62,5 @@
6262
'ask_mail_name' => 'Name that emails should appear from',
6363
'ask_encryption' => 'Encryption method to use',
6464
],
65-
'database' => [
66-
'host_warning' => 'It is highly recommended to not use "localhost" as your database host as we have seen frequent socket connection issues. If you want to use a local connection you should be using "127.0.0.1".',
67-
'host' => 'Database Host',
68-
'port' => 'Database Port',
69-
'database' => 'Database Name',
70-
'username_warning' => 'Using the "root" account for MySQL connections is not only highly frowned upon, it is also not allowed by this application. You\'ll need to have created a MySQL user for this software.',
71-
'username' => 'Database Username',
72-
'password_defined' => 'It appears you already have a MySQL connection password defined, would you like to change it?',
73-
'password' => 'Database Password',
74-
'connection_error' => 'Unable to connect to the MySQL server using the provided credentials. The error returned was ":error".',
75-
'creds_not_saved' => 'Your connection credentials have NOT been saved. You will need to provide valid connection information before proceeding.',
76-
'try_again' => 'Go back and try again?',
77-
],
78-
'app' => [
79-
'settings' => 'Enable UI based settings editor?',
80-
'author' => 'Egg Author Email',
81-
'author_help' => 'Provide the email address that eggs exported by this Panel should be from. This should be a valid email address.',
82-
'app_url_help' => 'The application URL MUST begin with https:// or http:// depending on if you are using SSL or not. If you do not include the scheme your emails and other content will link to the wrong location.',
83-
'app_url' => 'Application URL',
84-
'timezone_help' => 'The timezone should match one of PHP\'s supported timezones. If you are unsure, please reference http://php.net/manual/en/timezones.php.',
85-
'timezone' => 'Application Timezone',
86-
'cache_driver' => 'Cache Driver',
87-
'session_driver' => 'Session Driver',
88-
'queue_driver' => 'Queue Driver',
89-
'using_redis' => 'You\'ve selected the Redis driver for one or more options, please provide valid connection information below. In most cases you can use the defaults provided unless you have modified your setup.',
90-
'redis_host' => 'Redis Host',
91-
'redis_password' => 'Redis Password',
92-
'redis_pass_help' => 'By default a Redis server instance has no password as it is running locally and inaccessible to the outside world. If this is the case, simply hit enter without entering a value.',
93-
'redis_port' => 'Redis Port',
94-
'redis_pass_defined' => 'It seems a password is already defined for Redis, would you like to change it?',
95-
],
9665
],
9766
];

0 commit comments

Comments
 (0)