@@ -16,6 +16,11 @@ import { FileItemContainer } from "../../../../components/file-item";
1616import { FileItemContainerProps } from "../../../file-item/components/FileItemContainer/FileItemContainerProps" ;
1717import DropzoneLabel from "../DropzoneLabel/DropzoneLabel" ;
1818import { uploadPromiseAxios } from "../utils/dropzone-ui.upload.utils" ;
19+ import { DropzoneLocalizerSelector } from "../../../../localization" ;
20+ import {
21+ FunctionLabel ,
22+ LocalLabels ,
23+ } from "../../../../localization/localization" ;
1924
2025const Dropzone : React . FC < DropzoneProps > = ( props : DropzoneProps ) => {
2126 const {
@@ -50,6 +55,9 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
5055 fakeUploading,
5156 localization,
5257 } = mergeProps ( props , DropzonePropsDefault ) ;
58+
59+ const DropzoneLocalizer : LocalLabels =
60+ DropzoneLocalizerSelector ( localization ) ;
5361 //console.log("color:", color);
5462 //ref to the hidden input tag
5563 const inputRef = useRef < HTMLInputElement > ( null ) ;
@@ -97,7 +105,8 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
97105 } , [ uploadingMessage ] ) ;
98106
99107 /**
100- * Method for uploading FIles
108+ * Method for uploading Files
109+ * It will set all odd file id's as valid
101110 * @param files
102111 */
103112 const fakeUpload = ( file : FileValidated ) : Promise < FileValidated > => {
@@ -107,19 +116,19 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
107116 resolve ( {
108117 ...file ,
109118 uploadStatus : "success" ,
110- uploadMessage :
111- localization === "ES-es"
119+ uploadMessage : DropzoneLocalizer . fakeuploadsuccess as string ,
120+ /* localization === "ES-es"
112121 ? "EL archivo se subió correctamente"
113- : "File was succesfully uploaded" ,
122+ : "File was succesfully uploaded", */
114123 } ) ;
115124 } else {
116125 resolve ( {
117126 ...file ,
118127 uploadStatus : "error" ,
119- uploadMessage :
120- localization === "ES-es"
128+ uploadMessage : DropzoneLocalizer . fakeUploadError as string ,
129+ /* localization === "ES-es"
121130 ? "Erro al subir el archivo"
122- : "Error on Uploading" ,
131+ : "Error on Uploading", */
123132 } ) ;
124133 }
125134 } , 1500 ) ;
@@ -136,12 +145,16 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
136145 ) . length ;
137146 let totalRejected : number = 0 ;
138147 let currentCountUpload : number = 0 ;
148+ const uploadingMessenger : FunctionLabel =
149+ DropzoneLocalizer . uploadingMessage as FunctionLabel ;
150+
139151 setOnUploadStart ( true ) ;
140152 if ( missingUpload > 0 && url ) {
141153 setLocalMessage (
142- localization === "ES-es"
154+ uploadingMessenger ( `${ missingUpload } /${ totalNumber } ` ) ,
155+ /* localization === "ES-es"
143156 ? `Subiendo ${missingUpload}/${totalNumber} archivos`
144- : `uploading ${ missingUpload } /${ totalNumber } files` ,
157+ : `uploading ${missingUpload}/${totalNumber} files`, */
145158 ) ;
146159
147160 let uploadStartFiles : FileValidated [ ] = files . map ( ( f : FileValidated ) => {
@@ -158,9 +171,11 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
158171 let currentFile : FileValidated = uploadStartFiles [ i ] ;
159172 if ( currentFile . uploadStatus === "uploading" ) {
160173 setLocalMessage (
161- localization === "ES-es"
174+ uploadingMessenger ( `${ ++ currentCountUpload } /${ missingUpload } ` ) ,
175+
176+ /* localization === "ES-es"
162177 ? `Subiendo ${++currentCountUpload}/${missingUpload} archivos`
163- : `Uploading ${ ++ currentCountUpload } /${ missingUpload } files...` ,
178+ : `Uploading ${++currentCountUpload}/${missingUpload} files...`, */
164179 ) ;
165180 // const uploadedFile = await fakeUpload(currentFile);
166181
@@ -181,24 +196,25 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
181196 }
182197 }
183198 // upload group finished :D
199+ const finishUploadMessenger : FunctionLabel =
200+ DropzoneLocalizer . uploadFinished as FunctionLabel ;
184201 setLocalMessage (
185- localization === "ES-es"
186- ? `Archivos subidos: ${
187- missingUpload - totalRejected
188- } , Rechazados: ${ totalRejected } `
189- : `Uloaded files: ${
190- missingUpload - totalRejected
191- } , Rejected: ${ totalRejected } `,
202+ finishUploadMessenger ( missingUpload - totalRejected , totalRejected ) ,
203+ /* localization === "ES-es"
204+ ? `Archivos subidos: ${missingUpload - totalRejected}, Rechazados: ${totalRejected}`
205+ : `Uloaded files: ${missingUpload - totalRejected}, Rejected: ${totalRejected}`,
206+ */
192207 ) ;
193208 setTimeout ( ( ) => {
194209 setOnUploadStart ( false ) ;
195210 } , 2300 ) ;
196211 //console.log("queueFiles files:", queueFiles);
197212 } else {
198213 setLocalMessage (
199- localization === "ES-es"
214+ DropzoneLocalizer . noFilesMessage as string ,
215+ /* localization === "ES-es"
200216 ? `No hay archivos válidos pendientes por subir`
201- : `There is not any missing valid file for uploading` ,
217+ : `There is not any missing valid file for uploading`, */
202218 ) ;
203219 setTimeout ( ( ) => {
204220 setOnUploadStart ( false ) ;
@@ -317,7 +333,7 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
317333 //onDrop?.([]);
318334 } ;
319335 const handleChangeView = ( newView : "grid" | "list" ) => {
320- // console.log("new View", newView);
336+ // console.log("new View", newView);
321337 setLocalView ( newView ) ;
322338 onChangeView ?.( newView ) ;
323339 } ;
@@ -341,7 +357,7 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
341357 onChangeView = { handleChangeView }
342358 onUploadStart = { ! uploadOnDrop ? handleUploadStart : undefined }
343359 urlPresent = { url !== undefined }
344- localization = { localization !== "ES-es" ? "EN-en" : "ES-es" }
360+ localization = { localization }
345361 />
346362 ) }
347363 { value && files && files . length > 0 ? (
@@ -354,7 +370,7 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
354370 < DropzoneFooter
355371 accept = { accept }
356372 message = { onUploadStart ? localMessage : undefined }
357- localization = { localization !== "ES-es" ? "EN-en" : "ES-es" }
373+ localization = { localization }
358374 />
359375 ) }
360376 < div
0 commit comments