diff options
author | Stefan Giehl <stefan@piwik.org> | 2018-06-26 01:02:15 +0300 |
---|---|---|
committer | diosmosis <diosmosis@users.noreply.github.com> | 2018-06-26 01:02:15 +0300 |
commit | afcffaae6016e78c24c4de74242edde4b4f5fbd0 (patch) | |
tree | 55b342d7855641be061abe2790fce25163b57bf3 /plugins/CoreUpdater | |
parent | 1a76568aa7f85920e8f4b58e0aa2fd32f64de8ad (diff) |
Use translation for console update success message (#13100)
* Use translation for console update success message
* Replace Piwik w/ Matomo in core:update output
* fix integration test
* makes update command fully translatable
Diffstat (limited to 'plugins/CoreUpdater')
-rw-r--r-- | plugins/CoreUpdater/Commands/Update.php | 28 | ||||
-rw-r--r-- | plugins/CoreUpdater/lang/en.json | 11 | ||||
-rw-r--r-- | plugins/CoreUpdater/tests/Integration/Commands/UpdateTest.php | 2 |
3 files changed, 26 insertions, 15 deletions
diff --git a/plugins/CoreUpdater/Commands/Update.php b/plugins/CoreUpdater/Commands/Update.php index 5756bd02aa..d1e5868e80 100644 --- a/plugins/CoreUpdater/Commands/Update.php +++ b/plugins/CoreUpdater/Commands/Update.php @@ -39,9 +39,9 @@ class Update extends ConsoleCommand { $this->setName('core:update'); - $this->setDescription('Triggers upgrades. Use it after Piwik core or any plugin files have been updated.'); + $this->setDescription(Piwik::translate('CoreUpdater_ConsoleCommandDescription')); - $this->addOption('yes', null, InputOption::VALUE_NONE, 'Directly execute the update without asking for confirmation'); + $this->addOption('yes', null, InputOption::VALUE_NONE, Piwik::translate('CoreUpdater_ConsoleParameterDescription')); } /** @@ -61,13 +61,13 @@ class Update extends ConsoleCommand } if ($yes) { - $output->writeln("\nStarting the database upgrade process now. This may take a while, so please be patient."); + $output->writeln("\n" . Piwik::translate('CoreUpdater_ConsoleStartingDbUpgrade')); $this->makeUpdate($input, $output, false); - $this->writeSuccessMessage($output, array("Piwik has been successfully updated!")); + $this->writeSuccessMessage($output, array(Piwik::translate('CoreUpdater_PiwikHasBeenSuccessfullyUpgraded'))); } else { - $this->writeSuccessMessage($output, array('Database upgrade not executed.')); + $this->writeSuccessMessage($output, array(Piwik::translate('CoreUpdater_DbUpgradeNotExecuted'))); } $this->writeAlertMessageWhenCommandExecutedWithUnexpectedUser($output); @@ -82,7 +82,7 @@ class Update extends ConsoleCommand private function askForUpdateConfirmation(InputInterface $input, OutputInterface $output) { $helper = $this->getHelper('question'); - $question = new ConfirmationQuestion('<comment>A database upgrade is required. Execute update? (y/N) </comment>', false); + $question = new ConfirmationQuestion('<comment>'.Piwik::translate('CoreUpdater_ExecuteDbUpgrade').' (y/N) </comment>', false); return $helper->ask($input, $output, $question); } @@ -100,7 +100,7 @@ class Update extends ConsoleCommand $componentsWithUpdateFile = $updater->getComponentUpdates(); if (empty($componentsWithUpdateFile)) { - throw new NoUpdatesFoundException("Everything is already up to date."); + throw new NoUpdatesFoundException(Piwik::translate('CoreUpdater_AlreadyUpToDate')); } $output->writeln(array( @@ -159,7 +159,7 @@ class Update extends ConsoleCommand $migrationQueries = $this->getMigrationQueriesToExecute($updater); if(empty($migrationQueries)) { - $output->writeln(array(" *** Note: There are no SQL queries to execute. ***", "")); + $output->writeln(array(" *** ".Piwik::translate('CoreUpdater_ConsoleUpdateNoSqlQueries')." ***", "")); return; } @@ -171,13 +171,13 @@ class Update extends ConsoleCommand )); } - $output->writeln(array(" *** Note: this is a Dry Run ***", "")); + $output->writeln(array(" *** ".Piwik::translate('CoreUpdater_DryRun')." ***", "")); foreach ($migrationQueries as $query) { $output->writeln(" " . $query->__toString()); } - $output->writeln(array("", " *** End of Dry Run ***", "")); + $output->writeln(array("", " *** " . Piwik::translate('CoreUpdater_DryRunEnd') . " ***", "")); } private function doRealUpdate(Updater $updater, $componentsWithUpdateFile, OutputInterface $output) @@ -249,7 +249,7 @@ class Update extends ConsoleCommand )); } - throw new \RuntimeException("Piwik could not be updated! See above for more information."); + throw new \RuntimeException(Piwik::translate('CoreUpdater_ConsoleUpdateFailure')); } private function outputUpdaterWarnings(OutputInterface $output, $warnings) @@ -367,15 +367,15 @@ class Update extends ConsoleCommand $fileOwnerUserAndGroup = Filechecks::getOwnerOfPiwikFiles(); if (!$fileOwnerUserAndGroup || $processUserAndGroup == $fileOwnerUserAndGroup) { - // current process user/group appear to be same as the Piwik filesystem user/group -> OK + // current process user/group appear to be same as the Matomo filesystem user/group -> OK return; } $output->writeln( - sprintf("<comment>It appears you have executed this update with user %s, while your Piwik files are owned by %s. \n\nTo ensure that the Piwik files are readable by the correct user, you may need to run the following command (or a similar command depending on your server configuration):\n\n$ %s</comment>", + sprintf("<comment>%s</comment>", Piwik::translate('CoreUpdater_ConsoleUpdateUnexpectedUserWarning', [ $processUserAndGroup, $fileOwnerUserAndGroup, Filechecks::getCommandToChangeOwnerOfPiwikFiles() - ) + ])) ); } } diff --git a/plugins/CoreUpdater/lang/en.json b/plugins/CoreUpdater/lang/en.json index dc1e8cb1de..1b60e1dc7a 100644 --- a/plugins/CoreUpdater/lang/en.json +++ b/plugins/CoreUpdater/lang/en.json @@ -71,6 +71,17 @@ "UsingHttp": "using the non-secure HTTP connection", "UpgradeComplete": "Upgrade complete!", "UpgradePiwik": "Upgrade Matomo", + "ConsoleStartingDbUpgrade": "Starting the database upgrade process now. This may take a while, so please be patient.", + "DbUpgradeNotExecuted": "Database upgrade not executed.", + "ConsoleUpdateUnexpectedUserWarning": "It appears you have executed this update with user %1$s, while your Matomo files are owned by %2$s. \n\nTo ensure that the Matomo files are readable by the correct user, you may need to run the following command (or a similar command depending on your server configuration):\n\n$ %3$s", + "ConsoleUpdateFailure": "Matomo could not be updated! See above for more information.", + "ConsoleUpdateNoSqlQueries": "Note: There are no SQL queries to execute.", + "AlreadyUpToDate": "Everything is already up to date.", + "ExecuteDbUpgrade": "A database upgrade is required. Execute update?", + "DryRun": "Note: this is a Dry Run", + "DryRunEnd": "End of Dry Run", + "ConsoleCommandDescription": "Triggers upgrades. Use it after Matomo core or any plugin files have been updated.", + "ConsoleParameterDescription": "Directly execute the update without asking for confirmation", "VerifyingUnpackedFiles": "Verifying the unpacked files", "WarningMessages": "Warning messages:", "WeAutomaticallyDeactivatedTheFollowingPlugins": "We automatically deactivated the following plugins: %s", diff --git a/plugins/CoreUpdater/tests/Integration/Commands/UpdateTest.php b/plugins/CoreUpdater/tests/Integration/Commands/UpdateTest.php index bfb35380c5..c67ae90f15 100644 --- a/plugins/CoreUpdater/tests/Integration/Commands/UpdateTest.php +++ b/plugins/CoreUpdater/tests/Integration/Commands/UpdateTest.php @@ -112,7 +112,7 @@ class UpdateTest extends ConsoleCommandTestCase )); $this->assertEquals(1, $result, $this->getCommandDisplayOutputErrorMessage()); - $this->assertContains("Piwik could not be updated! See above for more information.", $this->applicationTester->getDisplay()); + $this->assertContains("Matomo could not be updated! See above for more information.", $this->applicationTester->getDisplay()); } private function assertDryRunExecuted($output) |