jQuery File Upload Basic Plus Ui and i18n

风格不统一 提交于 2019-12-13 00:52:59

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/34063348/jquery-file-upload-basic-plus-ui-and-i18n

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!