Skip to content

Commit

Permalink
OXDEV-5511 Translate exceptions
Browse files Browse the repository at this point in the history
Signed-off-by: Anton Fedurtsya <[email protected]>
  • Loading branch information
Sieg committed Jun 19, 2024
1 parent 18a1d01 commit 6e152d4
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 12 deletions.
2 changes: 1 addition & 1 deletion assets/out/src/js/base.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/out/src/js/base.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/js/base/medialibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@

error: function (file, responseJson, xhr) {
$(file.previewElement).addClass("dz-error")
.find('.dd-media-item-error').show().text(responseJson.error);
.find('.dd-media-item-error').show().text(ddh.translate(responseJson.error));
}
});

Expand Down
2 changes: 1 addition & 1 deletion src/Validation/Validator/FileExtensionValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function validateFile(FilePathInterface $filePath): void
}

if (!$isSupported) {
throw new ValidationFailedException("Invalid file extension");
throw new ValidationFailedException("OE_MEDIA_LIBRARY_EXCEPTION_INVALID_FILE_EXTENTION");
}
}
}
6 changes: 3 additions & 3 deletions src/Validation/Validator/FileNameValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,22 @@ private function checkForbiddenCharacters(string $fileName): void
$forbiddenCharacters = str_split(self::FORBIDDEN_CHARACTERS);
foreach ($forbiddenCharacters as $oneForbiddenCharacter) {
if (strpos($fileName, $oneForbiddenCharacter) !== false) {
throw new ValidationFailedException("Forbidden character found: " . $oneForbiddenCharacter);
throw new ValidationFailedException("OE_MEDIA_LIBRARY_EXCEPTION_FORBIDDEN_CHARACTER");
}
}
}

public function checkFilenameNotEmpty(string $fileName): void
{
if (!$fileName) {
throw new ValidationFailedException("Filename cannot be empty");
throw new ValidationFailedException("OE_MEDIA_LIBRARY_EXCEPTION_FILENAME_EMPTY");
}
}

public function checkFilenameDoesNotStartWithDot(string $fileName): void
{
if ($fileName[0] === '.') {
throw new ValidationFailedException("Filename cannot start with .");
throw new ValidationFailedException("OE_MEDIA_LIBRARY_EXCEPTION_FILENAME_STARTS_DOT");
}
}
}
2 changes: 1 addition & 1 deletion src/Validation/Validator/FileUploadStatusValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FileUploadStatusValidator implements FilePathValidatorInterface
public function validateFile(FilePathInterface $filePath): void
{
if (!file_exists($filePath->getPath())) {
throw new ValidationFailedException('File was not uploaded');
throw new ValidationFailedException("OE_MEDIA_LIBRARY_EXCEPTION_FILE_NOT_UPLOADED");
}
}
}
7 changes: 5 additions & 2 deletions views/admin_twig/de/ddoemedialibrary_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
'DD_MEDIA_RENAME_FILE_ERR' => 'Bild oder Ordner kann nicht umbenannt werden, weil es in Verwendung ist!',
'DD_MEDIA_IMG_URL' => 'Bild-URL',

'DD_MEDIA_EXCEPTION_INVALID_FILEEXT' => 'Der Upload von Dateien mit dieser Dateiendung ist nicht erlaubt!',

'OE_MEDIA_LIBRARY_EXCEPTION_INVALID_FILE_EXTENTION' => 'Ungültige Dateierweiterung',
'OE_MEDIA_LIBRARY_EXCEPTION_FORBIDDEN_CHARACTER' => 'Der Dateiname enthält nicht unterstützte Zeichen',
'OE_MEDIA_LIBRARY_EXCEPTION_FILENAME_EMPTY' => 'Dateiname darf nicht leer sein',
'OE_MEDIA_LIBRARY_EXCEPTION_FILENAME_STARTS_DOT' => 'Dateiname darf nicht mit "." beginnen',
'OE_MEDIA_LIBRARY_EXCEPTION_FILE_NOT_UPLOADED' => 'Datei wurde nicht hochgeladen',
);
7 changes: 5 additions & 2 deletions views/admin_twig/en/ddoemedialibrary_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
'DD_MEDIA_RENAME_FILE_ERR' => 'Image or folder can not be renamed because it is in use!',
'DD_MEDIA_IMG_URL' => 'Image URL',

'DD_MEDIA_EXCEPTION_INVALID_FILEEXT' => 'Uploading files with this file extension is not allowed!',

'OE_MEDIA_LIBRARY_EXCEPTION_INVALID_FILE_EXTENTION' => 'Invalid file extension',
'OE_MEDIA_LIBRARY_EXCEPTION_FORBIDDEN_CHARACTER' => 'The filename contains not supported characters',
'OE_MEDIA_LIBRARY_EXCEPTION_FILENAME_EMPTY' => 'Filename cannot be empty',
'OE_MEDIA_LIBRARY_EXCEPTION_FILENAME_STARTS_DOT' => 'Filename cannot start with "."',
'OE_MEDIA_LIBRARY_EXCEPTION_FILE_NOT_UPLOADED' => 'File was not uploaded',
);

0 comments on commit 6e152d4

Please sign in to comment.