diff --git a/PHPCI/Command/InstallCommand.php b/PHPCI/Command/InstallCommand.php index a4a0c4bb..ac5fbff2 100644 --- a/PHPCI/Command/InstallCommand.php +++ b/PHPCI/Command/InstallCommand.php @@ -15,6 +15,7 @@ use PDO; use b8\Config; use b8\Database; use b8\Store\Factory; +use PHPCI\Helper\Lang; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; @@ -39,16 +40,16 @@ class InstallCommand extends Command $this ->setName('phpci:install') - ->addOption('url', null, InputOption::VALUE_OPTIONAL, 'PHPCI Installation URL') - ->addOption('db-host', null, InputOption::VALUE_OPTIONAL, 'Database hostname') - ->addOption('db-name', null, InputOption::VALUE_OPTIONAL, 'Database name') - ->addOption('db-user', null, InputOption::VALUE_OPTIONAL, 'Database username') - ->addOption('db-pass', null, InputOption::VALUE_OPTIONAL, 'Database password') - ->addOption('admin-name', null, InputOption::VALUE_OPTIONAL, 'Admin username') - ->addOption('admin-pass', null, InputOption::VALUE_OPTIONAL, 'Admin password') - ->addOption('admin-mail', null, InputOption::VALUE_OPTIONAL, 'Admin e-mail') - ->addOption('config-path', null, InputOption::VALUE_OPTIONAL, 'Config file path', $defaultPath) - ->setDescription('Install PHPCI.'); + ->addOption('url', null, InputOption::VALUE_OPTIONAL, Lang::get('installation_url')) + ->addOption('db-host', null, InputOption::VALUE_OPTIONAL, Lang::get('db_host')) + ->addOption('db-name', null, InputOption::VALUE_OPTIONAL, Lang::get('db_name')) + ->addOption('db-user', null, InputOption::VALUE_OPTIONAL, Lang::get('db_user')) + ->addOption('db-pass', null, InputOption::VALUE_OPTIONAL, Lang::get('db_pass')) + ->addOption('admin-name', null, InputOption::VALUE_OPTIONAL, Lang::get('admin_name')) + ->addOption('admin-pass', null, InputOption::VALUE_OPTIONAL, Lang::get('admin_pass')) + ->addOption('admin-mail', null, InputOption::VALUE_OPTIONAL, Lang::get('admin_email')) + ->addOption('config-path', null, InputOption::VALUE_OPTIONAL, Lang::get('config_path'), $defaultPath) + ->setDescription(Lang::get('install_phpci')); } /** @@ -62,13 +63,13 @@ class InstallCommand extends Command $output->writeln(''); $output->writeln('******************'); - $output->writeln(' Welcome to PHPCI'); + $output->writeln(' '.Lang::get('welcome_to_phpci').''); $output->writeln('******************'); $output->writeln(''); $this->checkRequirements($output); - $output->writeln('Please answer the following questions:'); + $output->writeln(Lang::get('please_answer')); $output->writeln('-------------------------------------'); $output->writeln(''); @@ -111,9 +112,9 @@ class InstallCommand extends Command $errors = false; // Check PHP version: - if (!(version_compare(PHP_VERSION, '5.3.3') >= 0)) { + if (!(version_compare(PHP_VERSION, '5.3.8') >= 0)) { $output->writeln(''); - $output->writeln('PHPCI requires at least PHP 5.3.3 to function.'); + $output->writeln(''.Lang::get('phpci_php_req').''); $errors = true; } @@ -123,7 +124,7 @@ class InstallCommand extends Command foreach ($requiredExtensions as $extension) { if (!extension_loaded($extension)) { $output->writeln(''); - $output->writeln(''.$extension.' extension must be installed.'); + $output->writeln(''.Lang::get('extension_required', $extension).''); $errors = true; } } @@ -134,22 +135,22 @@ class InstallCommand extends Command foreach ($requiredFunctions as $function) { if (!function_exists($function)) { $output->writeln(''); - $output->writeln('PHPCI needs to be able to call the '.$function.'() function. Is it disabled in php.ini?'); + $output->writeln(''.Lang::get('function_required', $function).''); $errors = true; } } if (!function_exists('password_hash')) { $output->writeln(''); - $output->writeln('PHPCI requires the password_hash() function available in PHP 5.4, or the password_compat library by ircmaxell.'); + $output->writeln(''.Lang::get('function_required', $function).''); $errors = true; } if ($errors) { - throw new Exception('PHPCI cannot be installed, as not all requirements are met. Please review the errors above before continuing.'); + throw new Exception(Lang::get('requirements_not_met')); } - $output->writeln(' OK'); + $output->writeln(' '.Lang::get('ok').''); $output->writeln(''); } @@ -170,9 +171,9 @@ class InstallCommand extends Command $dialog = $this->getHelperSet()->get('dialog'); // Function to validate mail address. - $mailValidator =function ($answer) { + $mailValidator = function ($answer) { if (!filter_var($answer, FILTER_VALIDATE_EMAIL)) { - throw new Exception('Must be a valid email address.'); + throw new Exception(Lang::get('must_be_valid_email')); } return $answer; @@ -181,13 +182,13 @@ class InstallCommand extends Command if ($adminEmail = $input->getOption('admin-mail')) { $adminEmail = $mailValidator($adminEmail); } else { - $adminEmail = $dialog->askAndValidate($output, 'Your email address: ', $mailValidator, false); + $adminEmail = $dialog->askAndValidate($output, Lang::get('enter_email'), $mailValidator, false); } if (!$adminName = $input->getOption('admin-name')) { - $adminName = $dialog->ask($output, 'Enter your name: '); + $adminName = $dialog->ask($output, Lang::get('enter_name')); } if (!$adminPass = $input->getOption('admin-pass')) { - $adminPass = $dialog->askHiddenResponse($output, 'Enter your desired admin password: '); + $adminPass = $dialog->askHiddenResponse($output, Lang::get('enter_password')); } $admin['mail'] = $adminEmail; @@ -216,7 +217,7 @@ class InstallCommand extends Command // FUnction do validate URL. $urlValidator = function ($answer) { if (!filter_var($answer, FILTER_VALIDATE_URL)) { - throw new Exception('Must be a valid URL'); + throw new Exception(Lang::get('must_be_valid_url')); } return rtrim($answer, '/'); @@ -225,7 +226,7 @@ class InstallCommand extends Command if ($url = $input->getOption('url')) { $url = $urlValidator($url); } else { - $url = $dialog->askAndValidate($output, 'Your PHPCI URL ("http://phpci.local" for example): ', $urlValidator, false); + $url = $dialog->askAndValidate($output, Lang::get('enter_phpci_url'), $urlValidator, false); } $phpci['url'] = $url; @@ -250,19 +251,19 @@ class InstallCommand extends Command $dialog = $this->getHelperSet()->get('dialog'); if (!$dbHost = $input->getOption('db-host')) { - $dbHost = $dialog->ask($output, 'Please enter your MySQL host [localhost]: ', 'localhost'); + $dbHost = $dialog->ask($output, Lang::get('enter_db_host'), 'localhost'); } if (!$dbName = $input->getOption('db-name')) { - $dbName = $dialog->ask($output, 'Please enter your database name [phpci]: ', 'phpci'); + $dbName = $dialog->ask($output, Lang::get('enter_db_name'), 'phpci'); } if (!$dbUser = $input->getOption('db-user')) { - $dbUser = $dialog->ask($output, 'Please enter your database username [phpci]: ', 'phpci'); + $dbUser = $dialog->ask($output, Lang::get('enter_db_user'), 'phpci'); } if (!$dbPass = $input->getOption('db-pass')) { - $dbPass = $dialog->askHiddenResponse($output, 'Please enter your database password: '); + $dbPass = $dialog->askHiddenResponse($output, Lang::get('enter_db_pass')); } $db['servers']['read'] = $dbHost; @@ -298,7 +299,7 @@ class InstallCommand extends Command return true; } catch (Exception $ex) { - $output->writeln('PHPCI could not connect to MySQL with the details provided. Please try again.'); + $output->writeln(''.Lang::get('could_not_connect').''); $output->writeln('' . $ex->getMessage() . ''); } @@ -319,11 +320,11 @@ class InstallCommand extends Command protected function setupDatabase(OutputInterface $output) { - $output->write('Setting up your database... '); + $output->write(Lang::get('setting_up_db')); shell_exec(PHPCI_DIR . 'vendor/bin/phinx migrate -c "' . PHPCI_DIR . 'phinx.php"'); - $output->writeln('OK'); + $output->writeln(''.Lang::get('ok').''); } /** @@ -341,9 +342,9 @@ class InstallCommand extends Command $userService = new UserService($userStore); $userService->createUser($admin['name'], $admin['mail'], $admin['pass'], 1); - $output->writeln('User account created!'); + $output->writeln(''.Lang::get('user_created').''); } catch (\Exception $ex) { - $output->writeln('PHPCI failed to create your admin account.'); + $output->writeln(''.Lang::get('failed_to_create').''); $output->writeln('' . $ex->getMessage() . ''); die; } @@ -367,8 +368,8 @@ class InstallCommand extends Command $content = file_get_contents($this->configFilePath); if (!empty($content)) { - $output->writeln('The PHPCI config file exists and is not empty.'); - $output->writeln('If you were trying to update PHPCI, please use phpci:update instead.'); + $output->writeln(''.Lang::get('config_exists').''); + $output->writeln(''.Lang::get('update_instead').''); die; } } diff --git a/PHPCI/Command/UpdateCommand.php b/PHPCI/Command/UpdateCommand.php index 1b8becb1..32ce09b2 100644 --- a/PHPCI/Command/UpdateCommand.php +++ b/PHPCI/Command/UpdateCommand.php @@ -10,6 +10,7 @@ namespace PHPCI\Command; use Monolog\Logger; +use PHPCI\Helper\Lang; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputDefinition; @@ -40,7 +41,7 @@ class UpdateCommand extends Command { $this ->setName('phpci:update') - ->setDescription('Update the database to reflect modified models.'); + ->setDescription(Lang::get('update_phpci')); } /** @@ -50,25 +51,25 @@ class UpdateCommand extends Command { $this->verifyInstalled($output); - $output->write('Updating PHPCI database: '); + $output->write(Lang::get('updating_phpci')); shell_exec(PHPCI_DIR . 'vendor/bin/phinx migrate -c "' . PHPCI_DIR . 'phinx.php"'); - $output->writeln('Done!'); + $output->writeln(''.Lang::get('ok').''); } protected function verifyInstalled(OutputInterface $output) { if (!file_exists(PHPCI_DIR . 'PHPCI/config.yml')) { - $output->writeln('PHPCI does not appear to be installed.'); - $output->writeln('Please install PHPCI via phpci:install instead.'); + $output->writeln(''.Lang::get('not_installed').''); + $output->writeln(''.Lang::get('install_instead').''); die; } $content = file_get_contents(PHPCI_DIR . 'PHPCI/config.yml'); if (empty($content)) { - $output->writeln('PHPCI does not appear to be installed.'); - $output->writeln('Please install PHPCI via phpci:install instead.'); + $output->writeln(''.Lang::get('not_installed').''); + $output->writeln(''.Lang::get('install_instead').''); die; } } diff --git a/PHPCI/Languages/lang.en-gb.php b/PHPCI/Languages/lang.en-gb.php index 1f0e9433..ab04ed07 100644 --- a/PHPCI/Languages/lang.en-gb.php +++ b/PHPCI/Languages/lang.en-gb.php @@ -273,4 +273,46 @@ PHPCI', 'remove' => 'Remove »', 'search_packagist_for_more' => 'Search Packagist for more packages', 'search' => 'Search »', + + // Installer + 'installation_url' => 'PHPCI Installation URL', + 'db_host' => 'Database Host', + 'db_name' => 'Database Name', + 'db_user' => 'Database Username', + 'db_pass' => 'Database Password', + 'admin_name' => 'Admin Name', + 'admin_pass' => 'Admin Password', + 'admin_email' => 'Admin Email Address', + 'config_path' => 'Config File Path', + 'install_phpci' => 'Install PHPCI', + 'welcome_to_phpci' => 'Welcome to PHPCI', + 'please_answer' => 'Please answer the following questions:', + 'phpci_php_req' => 'PHPCI requires at least PHP 5.3.8 to function.', + 'extension_required' => 'Extension required: %s', + 'function_required' => 'PHPCI needs to be able to call the %s() function. Is it disabled in php.ini?', + 'requirements_not_met' => 'PHPCI cannot be installed, as not all requirements are met. + Please review the errors above before continuing.', + 'must_be_valid_email' => 'Must be a valid email address.', + 'must_be_valid_url' => 'Must be a valid URL.', + 'enter_name' => 'Admin Name:', + 'enter_email' => 'Admin Email:', + 'enter_password' => 'Admin Password:', + 'enter_phpci_url' => 'Your PHPCI URL ("http://phpci.local" for example): ', + + 'enter_db_host' => 'Please enter your MySQL host [localhost]: ', + 'enter_db_name' => 'Please enter your MySQL name [phpci]: ', + 'enter_db_user' => 'Please enter your MySQL username [phpci]: ', + 'enter_db_pass' => 'Please enter your MySQL password: ', + 'could_not_connect' => 'PHPCI could not connect to MySQL with the details provided. Please try again.', + 'setting_up_db' => 'Setting up your database... ', + 'user_created' => 'User account created!', + 'failed_to_create' => 'PHPCI failed to create your admin account.', + 'config_exists' => 'The PHPCI config file exists and is not empty.', + 'update_instead' => 'If you were trying to update PHPCI, please use phpci:update instead.', + + // Update + 'update_phpci' => 'Update the database to reflect modified models.', + 'updating_phpci' => 'Updating PHPCI database: ', + 'not_installed' => 'PHPCI does not appear to be installed.', + 'install_instead' => 'Please install PHPCI via phpci:install instead.', );