diff --git a/packages/console/src/ds-components/Uploader/FileUploader/index.tsx b/packages/console/src/ds-components/Uploader/FileUploader/index.tsx index 35d4383de6d..e9ea1415c11 100644 --- a/packages/console/src/ds-components/Uploader/FileUploader/index.tsx +++ b/packages/console/src/ds-components/Uploader/FileUploader/index.tsx @@ -8,7 +8,7 @@ import { useTranslation } from 'react-i18next'; import UploaderIcon from '@/assets/icons/upload.svg'; import useApi from '@/hooks/use-api'; -import { convertToFileExtensionArray } from '@/utils/uploader'; +import { convertToFileExtensionArray, formatBytes } from '@/utils/uploader'; import { Ring } from '../../Spinner'; @@ -94,7 +94,9 @@ function FileUploader = UserAssets>({ const fileSizeLimit = Math.min(maxSize, maxUploadFileSize); if (acceptedFile.size > fileSizeLimit) { - setUploadError(t('components.uploader.error_file_size', { size: fileSizeLimit / 1024 })); + setUploadError( + t('components.uploader.error_file_size', { limitWithUnit: formatBytes(fileSizeLimit) }) + ); return; } diff --git a/packages/phrases/src/locales/de/translation/admin-console/components.ts b/packages/phrases/src/locales/de/translation/admin-console/components.ts index 3a7155352ff..4c2c4d5dc34 100644 --- a/packages/phrases/src/locales/de/translation/admin-console/components.ts +++ b/packages/phrases/src/locales/de/translation/admin-console/components.ts @@ -5,7 +5,7 @@ const components = { image_limit: 'Lade ein Bild unter {{size, number}}KB hoch, nur {{extensions, list(style: narrow; type: conjunction;)}}.', error_upload: 'Etwas ist schiefgelaufen. Dateiupload fehlgeschlagen.', - error_file_size: 'Dateigröße ist zu groß. Bitte lade eine Datei unter {{size, number}}KB hoch.', + error_file_size: 'Dateigröße ist zu groß. Bitte lade eine Datei unter {{limitWithUnit}} hoch.', error_file_type: 'Dateityp wird nicht unterstützt. Nur {{extensions, list(style: narrow; type: conjunction;)}}.', error_file_count: 'Sie können nur 1 Datei hochladen.', diff --git a/packages/phrases/src/locales/en/translation/admin-console/components.ts b/packages/phrases/src/locales/en/translation/admin-console/components.ts index 1bd087436e4..cd6be12a3d2 100644 --- a/packages/phrases/src/locales/en/translation/admin-console/components.ts +++ b/packages/phrases/src/locales/en/translation/admin-console/components.ts @@ -5,7 +5,7 @@ const components = { image_limit: 'Upload image under {{size, number}}KB, {{extensions, list(style: narrow; type: conjunction;)}} only.', error_upload: 'Something went wrong. File upload failed.', - error_file_size: 'File size is too large. Please upload a file under {{size, number}}KB.', + error_file_size: 'File size is too large. Please upload a file under {{limitWithUnit}}.', error_file_type: 'File type is not supported. {{extensions, list(style: narrow; type: conjunction;)}} only.', error_file_count: 'You can only upload 1 file.', diff --git a/packages/phrases/src/locales/es/translation/admin-console/components.ts b/packages/phrases/src/locales/es/translation/admin-console/components.ts index 3533f44a2f7..5f55a2f7c8c 100644 --- a/packages/phrases/src/locales/es/translation/admin-console/components.ts +++ b/packages/phrases/src/locales/es/translation/admin-console/components.ts @@ -6,7 +6,7 @@ const components = { 'Sube imágenes de menos de {{size, number}}KB, solo {{extensions, list(style: narrow; type: conjunction;)}}.', error_upload: 'Algo salió mal. La subida de archivos falló.', error_file_size: - 'El archivo es demasiado grande. Por favor, sube un archivo de menos de {{size, number}}KB.', + 'El archivo es demasiado grande. Por favor, sube un archivo de menos de {{limitWithUnit}}.', error_file_type: 'El tipo de archivo no es compatible. Solo {{extensions, list(style: narrow; type: conjunction;)}}.', error_file_count: 'Solo puedes subir 1 archivo.', diff --git a/packages/phrases/src/locales/fr/translation/admin-console/components.ts b/packages/phrases/src/locales/fr/translation/admin-console/components.ts index cd0b42fd2d3..e2c6c972606 100644 --- a/packages/phrases/src/locales/fr/translation/admin-console/components.ts +++ b/packages/phrases/src/locales/fr/translation/admin-console/components.ts @@ -6,7 +6,7 @@ const components = { 'Téléchargez une image de moins de {{size, number}} Ko, uniquement {{extensions, list(style: narrow; type: conjunction;)}}.', error_upload: "Quelque chose s'est mal passé. La téléchargement de fichier a échoué.", error_file_size: - 'La taille du fichier est trop grande. Veuillez télécharger un fichier de moins de {{size, number}}Ko.', + 'La taille du fichier est trop grande. Veuillez télécharger un fichier de moins de {{limitWithUnit}}Ko.', error_file_type: "Le type de fichier n'est pas pris en charge. Uniquement {{extensions, list(style: narrow; type: conjunction;)}}.", error_file_count: 'Vous ne pouvez télécharger qu’un seul fichier.', diff --git a/packages/phrases/src/locales/it/translation/admin-console/components.ts b/packages/phrases/src/locales/it/translation/admin-console/components.ts index 1034a2cb9d2..72a66aa6b3c 100644 --- a/packages/phrases/src/locales/it/translation/admin-console/components.ts +++ b/packages/phrases/src/locales/it/translation/admin-console/components.ts @@ -5,7 +5,7 @@ const components = { image_limit: 'Carica immagini sotto i {{size, number}}KB, solo {{extensions, list(style: narrow; type: conjunction;)}}.', error_upload: 'Qualcosa è andato storto. Caricamento fallito.', - error_file_size: 'Il file è troppo grande. Carica un file sotto i {{size, number}}KB.', + error_file_size: 'Il file è troppo grande. Carica un file sotto i {{limitWithUnit}}.', error_file_type: 'Formato file non supportato. Sono accettati solo formati {{extensions, list(style: narrow; type: conjunction;)}}.', error_file_count: 'Puoi caricare solo 1 file.', diff --git a/packages/phrases/src/locales/ja/translation/admin-console/components.ts b/packages/phrases/src/locales/ja/translation/admin-console/components.ts index c43121cdb0a..c571a7ba68e 100644 --- a/packages/phrases/src/locales/ja/translation/admin-console/components.ts +++ b/packages/phrases/src/locales/ja/translation/admin-console/components.ts @@ -5,7 +5,7 @@ const components = { image_limit: '{{size, number}}KB以下のイメージをアップロードし、{{extensions, list(style: narrow; type: conjunction;)}}のみ許可します。', error_upload: 'エラーが発生しました。ファイルのアップロードに失敗しました。', - error_file_size: '{{size, number}}KB以下のファイルをアップロードしてください。', + error_file_size: '{{limitWithUnit}} 以下のファイルをアップロードしてください。', error_file_type: '{{extensions, list(style: narrow; type: conjunction;)}}のみサポートされます。', error_file_count: '1つのファイルしかアップロードできません。', diff --git a/packages/phrases/src/locales/ko/translation/admin-console/components.ts b/packages/phrases/src/locales/ko/translation/admin-console/components.ts index c5285ccf9a9..7d340624c38 100644 --- a/packages/phrases/src/locales/ko/translation/admin-console/components.ts +++ b/packages/phrases/src/locales/ko/translation/admin-console/components.ts @@ -5,7 +5,7 @@ const components = { image_limit: '{{size, number}}KB 미만의 {{extensions, list(style: narrow; type: conjunction;)}} 파일만 업로드하세요.', error_upload: '오류가 발생했습니다. 파일 업로드에 실패하였습니다.', - error_file_size: '파일 크기가 너무 커요. {{size, number}}KB 미만의 파일을 업로드해 주세요.', + error_file_size: '파일 크기가 너무 커요. {{limitWithUnit}} 미만의 파일을 업로드해 주세요.', error_file_type: '지원되지 않는 파일 유형이에요. {{extensions, list(style: narrow; type: conjunction;)}} 파일만 사용 가능해요.', error_file_count: '파일은 1개만 업로드 가능합니다.', diff --git a/packages/phrases/src/locales/pl-pl/translation/admin-console/components.ts b/packages/phrases/src/locales/pl-pl/translation/admin-console/components.ts index 8b80588cdd0..c767ab6954c 100644 --- a/packages/phrases/src/locales/pl-pl/translation/admin-console/components.ts +++ b/packages/phrases/src/locales/pl-pl/translation/admin-console/components.ts @@ -6,7 +6,7 @@ const components = { 'Wyślij obraz o rozmiarze mniejszym niż {{size, number}}KB, tylko w formacie {{extensions, list(style: narrow; type: conjunction;)}}.', error_upload: 'Coś poszło nie tak. Nie udało się wysłać pliku.', error_file_size: - 'Plik jest zbyt duży. Wyślij plik o rozmiarze mniejszym niż {{size, number}}KB.', + 'Plik jest zbyt duży. Wyślij plik o rozmiarze mniejszym niż {{limitWithUnit}}.', error_file_type: 'Ten typ pliku nie jest obsługiwany. Obsługiwane formaty to {{extensions, list(style: narrow; type: conjunction;)}}.', error_file_count: 'Możesz przesłać tylko 1 plik.', diff --git a/packages/phrases/src/locales/pt-br/translation/admin-console/components.ts b/packages/phrases/src/locales/pt-br/translation/admin-console/components.ts index 1335f16e252..6ac1ec207ba 100644 --- a/packages/phrases/src/locales/pt-br/translation/admin-console/components.ts +++ b/packages/phrases/src/locales/pt-br/translation/admin-console/components.ts @@ -6,7 +6,7 @@ const components = { 'Carregue imagens abaixo de {{size, number}}KB, apenas {{extensions, list(style: narrow; type: conjunction;)}}.', error_upload: 'Algo deu errado. Falha ao enviar arquivo.', error_file_size: - 'Tamanho do arquivo é muito grande. Por favor, envie um arquivo abaixo de {{size, number}}KB.', + 'Tamanho do arquivo é muito grande. Por favor, envie um arquivo abaixo de {{limitWithUnit}}.', error_file_type: 'Tipo de arquivo não é suportado. Apenas {{extensions, list(style: narrow; type: conjunction;)}}.', error_file_count: 'Você só pode enviar 1 arquivo.', diff --git a/packages/phrases/src/locales/pt-pt/translation/admin-console/components.ts b/packages/phrases/src/locales/pt-pt/translation/admin-console/components.ts index 84bbf5ab796..172c0dc15ab 100644 --- a/packages/phrases/src/locales/pt-pt/translation/admin-console/components.ts +++ b/packages/phrases/src/locales/pt-pt/translation/admin-console/components.ts @@ -6,7 +6,7 @@ const components = { 'Carregue imagens com menos de {{size, number}}KB, só {{extensions, list(style: narrow; type: conjunction;)}}.', error_upload: 'Algo correu mal. O carregamento do ficheiro falhou.', error_file_size: - 'O ficheiro é demasiado grande. Por favor carregue um ficheiro com menos de {{size, number}}KB.', + 'O ficheiro é demasiado grande. Por favor carregue um ficheiro com menos de {{limitWithUnit}}.', error_file_type: 'O tipo de ficheiro não é suportado. Apenas {{extensions, list(style: narrow; type: conjunction;)}}.', error_file_count: 'Só é possível carregar 1 ficheiro.', diff --git a/packages/phrases/src/locales/ru/translation/admin-console/components.ts b/packages/phrases/src/locales/ru/translation/admin-console/components.ts index cf59012a1f9..aa684daabec 100644 --- a/packages/phrases/src/locales/ru/translation/admin-console/components.ts +++ b/packages/phrases/src/locales/ru/translation/admin-console/components.ts @@ -6,7 +6,7 @@ const components = { 'Загрузите изображение размером менее {{size, number}} КБ, только {{extensions, list(style: narrow; type: conjunction;)}}.', error_upload: 'Что-то пошло не так. Загрузка файла не удалась.', error_file_size: - 'Размер файла слишком большой. Пожалуйста, загрузите файл размером менее {{size, number}} КБ.', + 'Размер файла слишком большой. Пожалуйста, загрузите файл размером менее {{limitWithUnit}}.', error_file_type: 'Тип файла не поддерживается. Допустимы только файлы типа {{extensions, list(style: narrow; type: conjunction;)}}.', error_file_count: 'Вы можете загрузить только 1 файл.', diff --git a/packages/phrases/src/locales/tr-tr/translation/admin-console/components.ts b/packages/phrases/src/locales/tr-tr/translation/admin-console/components.ts index b424ca5be00..93a37fa22af 100644 --- a/packages/phrases/src/locales/tr-tr/translation/admin-console/components.ts +++ b/packages/phrases/src/locales/tr-tr/translation/admin-console/components.ts @@ -5,8 +5,7 @@ const components = { image_limit: '{{size, number}}KB altındaki resimleri yükleyin, yalnızca {{extensions, list(style: narrow; type: conjunction;)}} dosyaları kabul edilir.', error_upload: 'Bir şeyler yanlış gitti. Dosya yüklenemedi.', - error_file_size: - 'Dosya boyutu çok büyük. Lütfen {{size, number}}KB altında bir dosya yükleyin.', + error_file_size: 'Dosya boyutu çok büyük. Lütfen {{limitWithUnit}} altında bir dosya yükleyin.', error_file_type: 'Dosya türü desteklenmiyor. Yalnızca {{extensions, list(style: narrow; type: conjunction;)}} dosyaları kabul edilir.', error_file_count: 'Sadece 1 dosya yükleyebilirsiniz.', diff --git a/packages/phrases/src/locales/zh-cn/translation/admin-console/components.ts b/packages/phrases/src/locales/zh-cn/translation/admin-console/components.ts index 100a779a60f..eb7c6c8db3e 100644 --- a/packages/phrases/src/locales/zh-cn/translation/admin-console/components.ts +++ b/packages/phrases/src/locales/zh-cn/translation/admin-console/components.ts @@ -5,7 +5,7 @@ const components = { image_limit: '上传图片大小不能超过 {{size, number}}KB,只支持 {{extensions, list(style: narrow; type: conjunction;)}} 格式的文件。', error_upload: '哎呀,出了些问题。文件上传失败。', - error_file_size: '文件太大了,请上传小于 {{size, number}}KB 的文件。', + error_file_size: '文件太大了,请上传小于 {{limitWithUnit}} 的文件。', error_file_type: '不支持该文件类型。只支持 {{extensions, list(style: narrow; type: conjunction;)}} 格式的文件。', error_file_count: '只能上传一个文件。', diff --git a/packages/phrases/src/locales/zh-hk/translation/admin-console/components.ts b/packages/phrases/src/locales/zh-hk/translation/admin-console/components.ts index aa90ef96a21..b7ddbb5d014 100644 --- a/packages/phrases/src/locales/zh-hk/translation/admin-console/components.ts +++ b/packages/phrases/src/locales/zh-hk/translation/admin-console/components.ts @@ -5,7 +5,7 @@ const components = { image_limit: '上傳圖片大小不能超過 {{size, number}}KB,只支援 {{extensions, list(style: narrow; type: conjunction;)}} 格式的檔案。', error_upload: '哎呀,出了些問題。檔案上傳失敗。', - error_file_size: '檔案太大了,請上傳小於 {{size, number}}KB 的檔案。', + error_file_size: '檔案太大了,請上傳小於 {{limitWithUnit}} 的檔案。', error_file_type: '不支援該檔案格式,只支援 {{extensions, list(style: narrow; type: conjunction;)}} 格式的檔案。', error_file_count: '你只能上載一個檔案。', diff --git a/packages/phrases/src/locales/zh-tw/translation/admin-console/components.ts b/packages/phrases/src/locales/zh-tw/translation/admin-console/components.ts index 7a6341d4842..0a431ca0fa9 100644 --- a/packages/phrases/src/locales/zh-tw/translation/admin-console/components.ts +++ b/packages/phrases/src/locales/zh-tw/translation/admin-console/components.ts @@ -5,7 +5,7 @@ const components = { image_limit: '上傳圖片大小不能超過 {{size, number}}KB,只支持 {{extensions, list(style: narrow; type: conjunction;)}} 格式的文件。', error_upload: '哎呀,出了些問題。文件上傳失敗。', - error_file_size: '文件太大了,請上傳小於 {{size, number}}KB 的文件。', + error_file_size: '文件太大了,請上傳小於 {{limitWithUnit}} 的文件。', error_file_type: '不支持該文件類型。只支持 {{extensions, list(style: narrow; type: conjunction;)}} 格式的文件。', error_file_count: '您只能上傳一個檔案。', diff --git a/packages/schemas/src/types/user-assets.ts b/packages/schemas/src/types/user-assets.ts index 931e29480f7..95aa2d530f4 100644 --- a/packages/schemas/src/types/user-assets.ts +++ b/packages/schemas/src/types/user-assets.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; -export const maxUploadFileSize = 8 * 1024 * 1024; // 8MB +export const maxUploadFileSize = 10 * 1024 * 1024; // 10 MB // Reference: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types export const allowUploadMimeTypes = [