From 629d8ad83a4148a820d306a62bcf772260694533 Mon Sep 17 00:00:00 2001 From: Torben Freudewald <92865600+torben-fr@users.noreply.github.com> Date: Tue, 20 Aug 2024 16:56:01 +0200 Subject: [PATCH] [BUGFIX] Fix translation messages in TypeConverter As some error messages were not translated but could use core translations those were adjusted. While doing that it seemed like some translations weren't working properly so those got fixed too --- .../ProfileImageUploadConverter.php | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/Classes/Property/TypeConverter/ProfileImageUploadConverter.php b/Classes/Property/TypeConverter/ProfileImageUploadConverter.php index 6222b50..edbdca0 100644 --- a/Classes/Property/TypeConverter/ProfileImageUploadConverter.php +++ b/Classes/Property/TypeConverter/ProfileImageUploadConverter.php @@ -160,14 +160,28 @@ private function importUploadedResource( */ private function validateUploadedFile(array $uploadedFileInformation, string $maxFileSize, string $allowedMimeTypes): void { + $typoScriptFrontendController = $this->getTypo3Request()->getAttribute('frontend.controller'); $maxFileSizeInBytes = GeneralUtility::getBytesFromSizeMeasurement($maxFileSize); $allowedMimeTypesArray = GeneralUtility::trimExplode(',', $allowedMimeTypes); if ($uploadedFileInformation['size'] > $maxFileSizeInBytes) { - throw new TypeConverterException('Uploaded file exceeds allowed file size', 1690538138); + $message = $typoScriptFrontendController->sL('EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530345'); + throw new TypeConverterException( + $typoScriptFrontendController->sL( + 'LLL:EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530345' + ), + 1690538138 + ); } if (!in_array($uploadedFileInformation['type'], $allowedMimeTypesArray, true)) { - throw new TypeConverterException('The uploaded file type is not allowed', 1695047315); + throw new TypeConverterException( + $typoScriptFrontendController->sL( + 'LLL:EXT:form/Resources/Private/Language/locallang.xlf:validation.error.1471708998', + null, + $uploadedFileInformation['type'], + ), + 1695047315 + ); } } @@ -275,28 +289,28 @@ protected function getUploadErrorMessage(int $errorCode): string switch ($errorCode) { case \UPLOAD_ERR_INI_SIZE: $this->logger?->error('The uploaded file exceeds the upload_max_filesize directive in php.ini.'); - return $typoScriptFrontendController->sL('EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530345'); + return $typoScriptFrontendController->sL('LLL:EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530345'); case \UPLOAD_ERR_FORM_SIZE: $this->logger?->error('The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.'); - return $typoScriptFrontendController->sL('EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530345'); + return $typoScriptFrontendController->sL('LLL:EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530345'); case \UPLOAD_ERR_PARTIAL: $this->logger?->error('The uploaded file was only partially uploaded.'); - return $typoScriptFrontendController->sL('EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530346'); + return $typoScriptFrontendController->sL('LLL:EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530346'); case \UPLOAD_ERR_NO_FILE: $this->logger?->error('No file was uploaded.'); - return $typoScriptFrontendController->sL('EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530347'); + return $typoScriptFrontendController->sL('LLL:EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530347'); case \UPLOAD_ERR_NO_TMP_DIR: $this->logger?->error('Missing a temporary folder.'); - return $typoScriptFrontendController->sL('EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530348'); + return $typoScriptFrontendController->sL('LLL:EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530348'); case \UPLOAD_ERR_CANT_WRITE: $this->logger?->error('Failed to write file to disk.'); - return $typoScriptFrontendController->sL('EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530348'); + return $typoScriptFrontendController->sL('LLL:EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530348'); case \UPLOAD_ERR_EXTENSION: $this->logger?->error('File upload stopped by extension.'); - return $typoScriptFrontendController->sL('EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530348'); + return $typoScriptFrontendController->sL('LLL:EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530348'); default: $this->logger?->error('Unknown upload error.'); - return $typoScriptFrontendController->sL('EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530348'); + return $typoScriptFrontendController->sL('LLL:EXT:form/Resources/Private/Language/locallang.xlf:upload.error.150530348'); } }