Search code examples
internationalizationjquery-file-upload

jQuery File Upload Basic Plus Ui and i18n


I use jQuery File Upload Basic Plus Ui for a multiple upload files. I need to display error messages in multiples languages (English, French and Spanish) but I don’t know how to create

messages: {
      maxNumberOfFiles: 'Maximum number of files exceeded',
      acceptFileTypes: 'File type not allowed'
      maxFileSize: 'File is too large',
      minFileSize: 'File is too smal
}

in multiple languages and how to declare the language for

file.error = settings.i18n('acceptFileTypes');

With the demo version, the errors messages are displayed ok.

Thanks


Solution

  • Here is how to instanciate fileupload plugin :

    $(document).ready(function() {
      $('#fileupload').fileupload({
         url: 'yoururl',
         acceptFileTypes: exttensionsRegex, 
         maxFileSize: yourmaxsize ,
         maxTotalFileSize: totalsize, 
         maxNumberOfFiles: numberoffiles , 
         messages: {
            maxNumberOfFiles: 'yourText',   
            acceptFileTypes: 'yourText' ,   
            maxFileSize:  'yourText',
            minFileSize:  'yourText'
         }
      });
    });
    

    If this javascript is generated by your server side code, then you can use the internationalization API to get the right messages and put them in place of yourText

    As for :

    file.error = settings.i18n('acceptFileTypes');
    

    Actually you don't need to do anything, let it how it is and it would work.

    I hope it can help