diff --git a/libraries/src/Plugin/CMSPlugin.php b/libraries/src/Plugin/CMSPlugin.php index 53dc692901523..71f5c435604a9 100644 --- a/libraries/src/Plugin/CMSPlugin.php +++ b/libraries/src/Plugin/CMSPlugin.php @@ -185,7 +185,7 @@ public function loadLanguage($extension = '', $basePath = JPATH_ADMINISTRATOR) * * @see sprintf */ - protected function translate(string $key): string + protected function translateKey(string $key): string { $language = $this->getApplication()->getLanguage(); diff --git a/plugins/api-authentication/basic/src/Extension/Basic.php b/plugins/api-authentication/basic/src/Extension/Basic.php index f5274d0ab5003..e902ab3c0f200 100644 --- a/plugins/api-authentication/basic/src/Extension/Basic.php +++ b/plugins/api-authentication/basic/src/Extension/Basic.php @@ -70,7 +70,7 @@ public function onUserAuthenticate($credentials, $options, &$response) if ($password === '') { $response->status = Authentication::STATUS_FAILURE; - $response->error_message = $this->translate('JGLOBAL_AUTH_EMPTY_PASS_NOT_ALLOWED'); + $response->error_message = $this->translateKey('JGLOBAL_AUTH_EMPTY_PASS_NOT_ALLOWED'); return; } @@ -106,7 +106,7 @@ public function onUserAuthenticate($credentials, $options, &$response) } else { // Invalid password $response->status = Authentication::STATUS_FAILURE; - $response->error_message = $this->translate('JGLOBAL_AUTH_INVALID_PASS'); + $response->error_message = $this->translateKey('JGLOBAL_AUTH_INVALID_PASS'); } } else { // Let's hash the entered password even if we don't have a matching user for some extra response time @@ -115,7 +115,7 @@ public function onUserAuthenticate($credentials, $options, &$response) // Invalid user $response->status = Authentication::STATUS_FAILURE; - $response->error_message = $this->translate('JGLOBAL_AUTH_NO_USER'); + $response->error_message = $this->translateKey('JGLOBAL_AUTH_NO_USER'); } } } diff --git a/plugins/api-authentication/token/src/Extension/Token.php b/plugins/api-authentication/token/src/Extension/Token.php index d428fdc4c8f7e..5383c56e8deda 100644 --- a/plugins/api-authentication/token/src/Extension/Token.php +++ b/plugins/api-authentication/token/src/Extension/Token.php @@ -95,7 +95,7 @@ public function onUserAuthenticate($credentials, $options, &$response): void // Default response is authentication failure. $response->type = 'Token'; $response->status = Authentication::STATUS_FAILURE; - $response->error_message = $this->translate('JGLOBAL_AUTH_FAIL'); + $response->error_message = $this->translateKey('JGLOBAL_AUTH_FAIL'); /** * First look for an HTTP Authorization header with the following format: diff --git a/plugins/task/requests/src/Extension/Requests.php b/plugins/task/requests/src/Extension/Requests.php index d4ff469f544d7..cfab6933a2496 100644 --- a/plugins/task/requests/src/Extension/Requests.php +++ b/plugins/task/requests/src/Extension/Requests.php @@ -128,7 +128,7 @@ protected function makeGetRequest(ExecuteTaskEvent $event): int try { $response = $this->httpFactory->getHttp([])->get($url, $headers, $timeout); } catch (Exception $e) { - $this->logTask($this->translate('PLG_TASK_REQUESTS_TASK_GET_REQUEST_LOG_TIMEOUT')); + $this->logTask($this->translateKey('PLG_TASK_REQUESTS_TASK_GET_REQUEST_LOG_TIMEOUT')); return TaskStatus::TIMEOUT; } @@ -144,7 +144,7 @@ protected function makeGetRequest(ExecuteTaskEvent $event): int $this->snapshot['output_file'] = $responseFilename; $responseStatus = 'SAVED'; } catch (Exception $e) { - $this->logTask($this->translate('PLG_TASK_REQUESTS_TASK_GET_REQUEST_LOG_UNWRITEABLE_OUTPUT'), 'error'); + $this->logTask($this->translateKey('PLG_TASK_REQUESTS_TASK_GET_REQUEST_LOG_UNWRITEABLE_OUTPUT'), 'error'); $responseStatus = 'NOT_SAVED'; } @@ -155,7 +155,7 @@ protected function makeGetRequest(ExecuteTaskEvent $event): int > Response: $responseStatus EOF; - $this->logTask($this->translate('PLG_TASK_REQUESTS_TASK_GET_REQUEST_LOG_RESPONSE', $responseCode)); + $this->logTask($this->translateKey('PLG_TASK_REQUESTS_TASK_GET_REQUEST_LOG_RESPONSE', $responseCode)); if ($response->code !== 200) { return TaskStatus::KNOCKOUT; diff --git a/plugins/task/sitestatus/src/Extension/SiteStatus.php b/plugins/task/sitestatus/src/Extension/SiteStatus.php index 0bd65d0361c36..17bb92780c60d 100644 --- a/plugins/task/sitestatus/src/Extension/SiteStatus.php +++ b/plugins/task/sitestatus/src/Extension/SiteStatus.php @@ -139,7 +139,7 @@ public function alterSiteStatus(ExecuteTaskEvent $event): void $newStatus = $config['offline'] ? 'offline' : 'online'; $exit = $this->writeConfigFile(new Registry($config)); - $this->logTask($this->translate('PLG_TASK_SITE_STATUS_TASK_LOG_SITE_STATUS', $oldStatus, $newStatus)); + $this->logTask($this->translateKey('PLG_TASK_SITE_STATUS_TASK_LOG_SITE_STATUS', $oldStatus, $newStatus)); $this->endRoutine($event, $exit); } @@ -161,7 +161,7 @@ private function writeConfigFile(Registry $config): int // Attempt to make the file writeable. if (file_exists($file) && Path::isOwner($file) && !Path::setPermissions($file)) { - $this->logTask($this->translate('PLG_TASK_SITE_STATUS_ERROR_CONFIGURATION_PHP_NOTWRITABLE'), 'notice'); + $this->logTask($this->translateKey('PLG_TASK_SITE_STATUS_ERROR_CONFIGURATION_PHP_NOTWRITABLE'), 'notice'); } try { @@ -169,7 +169,7 @@ private function writeConfigFile(Registry $config): int $configuration = $config->toString('PHP', array('class' => 'JConfig', 'closingtag' => false)); File::write($file, $configuration); } catch (Exception $e) { - $this->logTask($this->translate('PLG_TASK_SITE_STATUS_ERROR_WRITE_FAILED'), 'error'); + $this->logTask($this->translateKey('PLG_TASK_SITE_STATUS_ERROR_WRITE_FAILED'), 'error'); return Status::KNOCKOUT; } @@ -181,7 +181,7 @@ private function writeConfigFile(Registry $config): int // Attempt to make the file un-writeable. if (Path::isOwner($file) && !Path::setPermissions($file, '0444')) { - $this->logTask($this->translate('PLG_TASK_SITE_STATUS_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE'), 'notice'); + $this->logTask($this->translateKey('PLG_TASK_SITE_STATUS_ERROR_CONFIGURATION_PHP_NOTUNWRITABLE'), 'notice'); } return Status::OK; diff --git a/tests/Unit/Libraries/Cms/Plugin/CMSPluginTest.php b/tests/Unit/Libraries/Cms/Plugin/CMSPluginTest.php index 669f68d60b187..19bf0e2772e1a 100644 --- a/tests/Unit/Libraries/Cms/Plugin/CMSPluginTest.php +++ b/tests/Unit/Libraries/Cms/Plugin/CMSPluginTest.php @@ -264,7 +264,7 @@ public function testTranslateWithoutArguments() { public function test(): string { - return parent::translate('unit'); + return parent::translateKey('unit'); } }; $plugin->setApplication($app); @@ -292,7 +292,7 @@ public function testTranslateWithArguments() { public function test(): string { - return parent::translate('unit', 1, 'two'); + return parent::translateKey('unit', 1, 'two'); } }; $plugin->setApplication($app);