UNPKG

@wordpress/upload-media

Version:
102 lines (101 loc) 3.09 kB
// packages/upload-media/src/error-messages.ts import { __, sprintf } from "@wordpress/i18n"; import { ErrorCode } from "./upload-error.mjs"; function getErrorMessage(code, fileName) { const messages = { [ErrorCode.EMPTY_FILE]: { title: __("Empty file"), description: sprintf( /* translators: %s: file name */ __('"%s" is empty.'), fileName ), action: __("Please choose a different file.") }, [ErrorCode.SIZE_ABOVE_LIMIT]: { title: __("File too large"), description: sprintf( /* translators: %s: file name */ __('"%s" exceeds the maximum upload size.'), fileName ), action: __("Please reduce the file size and try again.") }, [ErrorCode.MIME_TYPE_NOT_SUPPORTED]: { title: __("Unsupported file type"), description: sprintf( /* translators: %s: file name */ __('"%s" is not a supported file type.'), fileName ), action: __("Please upload a different file format.") }, [ErrorCode.MIME_TYPE_NOT_ALLOWED_FOR_USER]: { title: __("File type not allowed"), description: sprintf( /* translators: %s: file name */ __('You are not allowed to upload "%s".'), fileName ), action: __("Please contact your site administrator.") }, [ErrorCode.HEIC_DECODE_ERROR]: { title: __("HEIC decode failed"), description: sprintf( /* translators: %s: file name */ __('Failed to decode HEIC file "%s".'), fileName ), action: __("Try converting the image to JPEG or PNG first.") }, [ErrorCode.IMAGE_TRANSCODING_ERROR]: { title: __("Image processing failed"), description: sprintf( /* translators: %s: file name */ __('Failed to process "%s".'), fileName ), action: __("The image may be corrupted. Try a different file.") }, [ErrorCode.IMAGE_ROTATION_ERROR]: { title: __("Image rotation failed"), description: sprintf( /* translators: %s: file name */ __('Failed to rotate "%s".'), fileName ), action: __("The image may be corrupted. Try a different file.") }, [ErrorCode.MEDIA_TRANSCODING_ERROR]: { title: __("Media processing failed"), description: sprintf( /* translators: %s: file name */ __('Failed to convert "%s" to the target format.'), fileName ), action: __("The file may be corrupted. Try a different file.") }, [ErrorCode.GENERAL]: { title: __("Upload failed"), description: sprintf( /* translators: %s: file name */ __('Failed to upload "%s".'), fileName ), action: __("Please try again.") } }; return messages[code] || { title: __("Upload failed"), description: sprintf( /* translators: %s: file name */ __('Failed to upload "%s".'), fileName ), action: __("Please try again.") }; } export { getErrorMessage }; //# sourceMappingURL=error-messages.mjs.map